Safari/Chrome Not Posting Values When Changed Via Javascript
I have a few hidden form elements like so:
<input type="hidden" name="numberOfAdults" />
I then have an onsubmit function that does some addition and puts the sum into the hidden fields:
form.numberOfAdults.value = numAdults;
The form is submitted depending on if this function returns true or false. When the form is submitted, IE7+ and Firefox show the changed value from the onsubmit function. Safari and Chrome do not. However, if I give the hidden inputs default values:
<input type="hidden" name="numberOfAdults" value="2" />
Then the value gets passed. Why are Safari and Chrome ignori开发者_运维知识库ng these changed values?
EDIT: Here is the complete code: http://jsfiddle.net/2q8SX/
just a wild guess:
give your submit button:
onclick="yourFunction(); return false;"
and add to your function() as it's last command:
document.getElementByTagName('form').submit();
精彩评论