|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to populate these form fields using the following code:
<form name="thisform" action="next_step.php"> <input type="hidden" name="product_id" value="" /> <input type="hidden" name="prod_id[]" value="" /> </form> <area shape="rect" coords="98,69,580,85" id="20" alt="Carbonite Jack Hammer" title="11.95000" href="javascript:void(0);" onclick="document.thisform.getElementById('product_id').val ue='20'; document.thisform.getElementById('prod_id[]').value='20'; document.thisform.submit(); return false;"/> Whenever I test for the value of 'product_id' or prod_id[] it is always blank and never gets assigned the value from the <area> tag code. What would be the best way to handle this? Any suggestions? Thanks. |
|
#2
|
|||
|
|||
|
This is technicaly a php and not Javascript forum, but your problem is that when using getElementById() the form fields actually have to have the id you're placing the value in. You are trying to use the name value instead.
Code:
<form name="thisform" action="next_step.php">
<input type="hidden" id="product_id" name="product_id" value="" />
<input type="hidden" id="prod_id[]" name="prod_id[]" value="" />
</form>
<area shape="rect" coords="98,69,580,85" id="20" alt="Carbonite Jack Hammer" title="11.95000" href="javascript:void(0);" onclick="document.thisform.getElementById('product_id').val ue='20'; document.thisform.getElementById('prod_id[]').value='20'; document.thisform.submit(); return false;"/>
I did the second one also, but I'm not sure that an id can have [] in it... so you may still have a problem there. Last edited by MatthewJ : November 4th, 2009 at 02:04 PM. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > forms - Populate Form Field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|