0

And enter Html select in another select but the second select does not send information either by GET or by POST. I don't know where I will add the id = "" and name = "" in JavaScript, to make it work.

<select id="type" name="type">
    <option value="item1">item1</option>
    <option value="item2">item2</option>
    <option value="item3">item3</option>
</select>

<select id="size">
    <option value="">-- select one -- </option>
</select>

<script>    
    $(document).ready(function() {

    $("#type").change(function() {
        var val = $(this).val();
        if (val == "item1") {
            $("#size").html("<option value='test'>item1: test 1</option><option value='test2'>item1: test 2</option>");
        } else if (val == "item2") {
            $("#size").html("<option value='test'>item2: test 1</option><option value='test2'>item2: test 2</option>");

        } else if (val == "item3") {
            $("#size").html("<option value='test'>item3: test 1</option><option value='test2'>item3: test 2</option>");

        }
    });


});                                 
</script>   

With type it works, but it receives only the information of the first select

It is included in form. And the source code is this: http://jsfiddle.net/YPsqQ/

1 Answer 1

1

By "it works" I assume you mean these elements are part of a <form> which is being submitted at some later point? The first <select> sends its value in that form because it has a name:

<select id="type" name="type">

The second <select> is missing its name, so a <form> has no way to include it. Simply give it a name:

<select id="size" name="size">
Sign up to request clarification or add additional context in comments.

3 Comments

It is included in form. And the source code is this. jsfiddle.net/YPsqQ
@diaconuliviu: Then what exactly is the problem? How is this failing?
is work , I didn't realize that javascript is associated with the second select

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.