I have a page where I want to populate a secondary select box based on what you select in the first select box.
Select box1 contains a list of different courses students can take.
When you select a course, select box2 is populated with different start dates for the selected course.
I can't have a pure javascript solution for this, as the dates dynamically change, and are extracted from a database at run-time.
--------
So to my problem.
I've made a dummy page with two select boxes, and a script that queries a dummy table and presents the result as described above.
I have an "onchange" event in the first select box, that submits the form when you select anything (see code below).
This test page works just fine.
I have basically just cut and pasted the code from the dummy page to the real page which contains more elements and styling. (I have changed the form name as described below, so that is not the culprit.)
However, when I transfer the code to the production page, the onchange event stops working, and it refuses to submit the page.
The primary "submit button" at the end of the form works, but the onchange-submit doesn't.
(The recieving/processing page registers all the POST variables into SESSION variables but won't process the page until it recieves the value of the real submit button. As long as that is missing, it just relocates the user to the forms page again, but with the previously posted data intact. Those values are used to repopulate the form.)
Are there any alternative ways to make the page automatically submit when a selection is made in the first select box, or can anyone immediately see why the onchange event fails as it stands now?
The "pamelding" in [minicode]this.document.pamelding.submit()[/minicode] is the name of the form.Code:<select onchange="this.document.pamelding.submit()" name="kurs"style="width:250px; font-size: 16px; background-color:#FFFFCC" > <option value="<?php echo $kurs ?>" <?php if(@$redK) echo $redK; ?>><?php echo $knavn ?></option> <option value="1" style="background-color:#12AE06">Nybegynnerkurs</option> <option value="2" style="background-color:#B8FF29">VK 1</option> .....and so on.