megat ahmad mustaqim megat ahmad mustaqim - 2 years ago 53
HTML Question

Can an input field's value attribute differ from the text it displays?

I have a form input field and want to display a medicine-name in the field, but when I submit the form, it needs to submit the medicine-id. How can I do that?

<td>Medicine Name </td>
<td> :
<input type="text" name="medicine_ID" id="medicine_ID" value="<?php echo $_GET['medicine_Name'];?>"/>

Answer Source

You could add the medicine-ID as an hidden input field and the medicine-Name as the visible input field. When you submit the form you can access both values and deal with them as you see fit.

     <td width="100">Medicine Name </td>
     <td width="327" colspan="2"> : 
         <input type="text" name="medicine_NAME" id="medicine_NAME"  value="<?php echo  $_GET['medicine_Name'];?>"  size="25" required/>
         <input type="hidden" name="medicine_ID" id="medicine_ID"  value="<?php echo  $_GET['medicine_Id'];?>" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download