user3498478
user3498478

Reputation: 71

selected option from drop down fills another text box/drop down value value on change

I have this form that changes values in second drop down based on first drop down values chosen. It works as designed but only on the first selected choice. If I re-select a different value in drop down one (for a second time) it doesn't change values in drop down two (it only changes it per the first choice). In this case if the user has entered in a wrong value the first time there is no-way to change it unless the page is reloaded. Here is a fiddle http://jsfiddle.net/k4hYE/53/

    var objArray = {"On-Call Service": "Per Pickup"};
    var objArray = {"Every Six Months (2 Stops Annually)": "Per Pickup"};
    var objArray = {"Every Three Months (4 Stops Annually)": "Every Three Months"};
    var objArray = {"Every Other Month (6 Stops Annually)": "Every Other Month"};
    var objArray = {"Monthly (12-13 Stops Annually)": "Per Month"};
    var objArray = {"Every Other Week (26 Stops Annually)": "Per Month"};
    var objArray = {"Every Week (52 Stops Annually)": "Per Month"};


    $("#00NA00000047Jk8").change(function()
    {
     var ddText = $(this).val();
    $.each(objArray,function(key,value)
    {
    if(ddText == key)
        $("#00NA0000005wIiU").val(value);
    });
    });

Upvotes: 0

Views: 412

Answers (1)

Andrew Coder
Andrew Coder

Reputation: 1048

You are resetting your array on each iteration.

Fixed: http://jsfiddle.net/k4hYE/55/

Upvotes: 0

Related Questions