I am sure this is (hopefully) going to turn out to be a really stupid question.
I'm making some basic alterations to a form for a client's website - evidently, the site loads a php script in an iFrame that writes 2/3 of the form. The rest of the form is written in a JS file included on the original page after the php script has ended.
I had to, among other things, move a select into the part of the page that is written in JavaScript.
' <td class="ttcell itemcell1 continent">' +
' <select name="continent" id="continent" class="long-field" onchange="window.parent.calcTotals()">' +
' <option value="NA">North America</option>' +
' <option value="SA" selected>South America</option>' +
' <option value="EU">Europe</option>' +
' <option value="MO">Middle-Orient</option>' +
' <option value="AA">Asia-Australia</option>' +
' </select>' +
' </td>' +
I need to calculate a displayed value when the dropdown selection changes. If I check the value in a JavaScript file included in the PHP document, which is called on form submit, I can check the value there. However, I can't seem to find anywhere to bind the function. If I have onclick as above in the original code, the event fires, but the selected value never changes. If I check the value of the select in another function in the same JavaScript file, the value doesn't change.
The only place the change is reflected is when called from a function in the other PHP file...but trying to bind the event there doesn't seem to work. I am starting to go slightly crazy...
Edit: Solved by binding a click event in JS1 which called a function in JS2 returning the value. In JS1 I was never able to read the true value of the select, and as such could never bind a change event.
onclick, but that's not the same asonchange....