how to send data with form label element?

2019-07-20 19:47发布

I should send data with form when submit button pressed.This value should be invisible and I used <label name=r_id id=r_id style="visible:hidden"> 1 </div>

This is my form

   <form id="send_message" action="lib/send_message.php" method="post">

    <textarea name="message" cols="45" rows="3" id="message"></textarea>
    <label  name="r_id" id="r_id" style="visible:hidden"> 1 </label>

    <input type="submit" name="Submit" value="Submit"> 
    <input type="reset"    name="Submit2" value="Reset">

But in my .php file It shows only message ,id is empty.

I used $message= $_POST['message'] and $r_ID=$_POST['r_id'] ;

EDIT

I should write that this label value must be change.And I am changing it with Jquery where the mouse clicked it gets tags id.Can I change value attribute with Jquery ?

标签: html forms label
3条回答
贼婆χ
2楼-- · 2019-07-20 20:07
input type="hidden"

are made for this and they won't appear if CSS are disabled (but of course they'll still appear in the HTML code)

查看更多
何必那么认真
3楼-- · 2019-07-20 20:13

You're after a hidden input.

<input type="hidden" name="r_id" value="1"/>
查看更多
Summer. ? 凉城
4楼-- · 2019-07-20 20:21

LABELs are not form elements that can hold or send data. They are captions tied to form elements.

<INPUT TYPE="hidden" name="r_id" id="r_id" VALUE="1"/>

This should do what you want.

查看更多
登录 后发表回答