Safari / Chrome doesn't post values ​​when changed using Javascript

I have some hidden form elements:

<input type="hidden" name="numberOfAdults" />

Then I have an onsubmit function that does some addition and puts the amount in hidden fields:

form.numberOfAdults.value = numAdults;

The form is submitted depending on whether this function returns true or false. When the form is submitted, IE7 + and Firefox display the changed value from the onsubmit function. Safari and Chrome not. However, if I give hidden default input values:

    <input type="hidden" name="numberOfAdults" value="2" />

Then the value is transmitted. Why are Safari and Chrome ignoring these changed values?

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

+3
source share
1 answer

just a wild guess:

send submit button:

onclick="yourFunction(); return false;"

() :

document.getElementByTagName('form').submit();
+1

Source: https://habr.com/ru/post/1790584/


All Articles