Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ignoring these changed values?

EDIT: Here is the complete code: http://jsfiddle.net/2q8SX/

like image 432
Jarred Avatar asked Feb 05 '26 02:02

Jarred


1 Answers

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();
like image 132
david.wosnitza Avatar answered Feb 06 '26 15:02

david.wosnitza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!