megat ahmad mustaqim megat ahmad mustaqim - 6 months ago 9
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?

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

Answer

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.

 <tr>
     <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'];?>" />
    </td>
</tr>