0

I have a page with a form with two html select tags. The first html select tag is populated with data from php.

<select name="groep" id="groep">
        <?php 
        for ($i = 0; $i < $aantal; $i++) {
            echo "<option value='" . $groepen[$i] . "'>" . $groepen[$i] . "</option>";
        } ?></select>

The second html select tag is populated with data based on the selection from the first html select tag (with a on('change') jquery function on the first html select tag).

<select name="school"><option>Selecteer eerst de groep.</option></select>

-

$(document).on('change', '#groep', function() {

        var str = "";
        $( "#groep option:selected" ).each(function()
        {
            str += $( this ).text() + " ";
        });


        var url = "../getSchools.php?q=" + $( "#groep option:selected").text();

        $( "td#schoolselect" ).load( url );
    });

Now i want both selected values from both select tags written to my mysqldb. Problem is that the selected value from the second select tag isn't getting passed when submitted.

What could be my problem?

1
  • This looks rather tedious method,WhY dont you get all the items of 2nd select box with the matching ids from first select and keep them hidden on load and then on change of 1st select perform operations correspondingly , if that makes sense? Commented Sep 10, 2015 at 14:27

1 Answer 1

2

You need to add an id to your second select

<select name="schoolselect" id="schoolselect"><option>Selecteer eerst de groep.</option></select>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.