Madhan Madhan - 1 year ago 109
PHP Question

Is display none gives value on $_POST?

<div style="display:none">
<input type='text' name='test_val' value='5'>
</div>



<div>
<input type='text' name='test_val' value='10'>
</div>


which value of test_val will be POST?

Answer Source

Hiding field in any way won't hide the value. If you want to prevent value from being sent, your field has to have "disabled" attribute. If you want to access both fields values (and have a same name) then you have to update your names. For example:

<div style="display:none">
   <input type='text' name='test_val[]' value='5'>
</div>

<div>
  <input type='text' name='test_val[]' value='10'>
</div>

Then, in PHP you can access your field values:

$_POST['test_val'][0] == 5
$_POST['test_val'][1] == 10
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download