How can I change a form's input value with javascript

Posted by Biroka on Stack Overflow See other posts from Stack Overflow or by Biroka
Published on 2010-06-14T09:28:38Z Indexed on 2010/06/14 9:32 UTC
Read the original article Hit count: 249

Filed under:
|
|
|
|

How can I change a form's input value with javascript depending on witch combobox item is selected. I have a form with some imported values, and there is a field of witch imported value can be changed via a combobox. In my case:

print("<input type='hidden' name='issue_array[{$issue["nr"]}][\"supplier\"]' value='{$issue["supplier"]}' />");

I have a combobox, that if I change it's value, should change the value of the input above.

This is what I tried:

print("<select name='supplier_combo' onchange='setSupplierInputValue(this.value, ${issue['nr']})'>");

and the script:

  echo "\r\n" . '<SCRIPT TYPE="text/javascript">' . "\r\n";
  echo 'function setSupplierInputValue(value, issue_nr)' . "\r\n";
  echo '{' . "\r\n";     
  echo '      issue_array[issue_nr]["supplier"] = value;';         
  echo '}' . "\r\n";     
  echo '</SCRIPT>'. "\r\n"; 

But it doesn't work, please help.

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript