I''m trying to update a hidden field with java script and I''m only
getting one of the values from my select stament. Here is the code
below.
25
50
document.write(''
if (document.test.on0.options[document.test.on0.selectedIndex].value
== 50)
document.write(''value="275"'');
else
document.write(''value="250"'');
document.write(''>'');
No matter what I do the value of "amount" is always 250... any ideas
here?
Aaron
解决方案
we***************@gmail.com said:
>
I''m trying to update a hidden field with java script and I''m only
getting one of the values from my select stament. Here is the code
below.
25
50
document.write(''
if (document.test.on0.options[document.test.on0.selectedIndex].value
== 50)
document.write(''value="275"'');
else
document.write(''value="250"'');
document.write(''>'');
No matter what I do the value of "amount" is always 250... any ideas
here?
The block of code that contains the document.write() lines is only
executed once, as the page is loading. It won''t update the value
when a selection is made.
If you want document.test.amount.value to be updated when a selection
is made, you''ll need to add an onchange handler to the
If you only want it to be updated as your form is submitted, you should
add an onsubmit handler to the
--
At the time of execution, the form select''s value is 25.
What you are looking for is something such as this....
25
50
function alertInput(){
var selID = document.getElementById(''on0'');
document.getElementById(''amount'').value =
parseInt(
(selID).options