how to send data with form label element?

2019-07-20 20:09发布

问题:

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 ?

回答1:

You're after a hidden input.

<input type="hidden" name="r_id" value="1"/>


回答2:

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:

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.



标签: html forms label