You are viewing limited content. For full access, please sign in.

Question

Question

Matching drop down list

asked on September 5, 2014 Show version history

I am currently working on a form that if the user selects an option either yes or no two other drop downs are to match. I am having some trouble trying to set the values identically to each other. Here is a block of my code which checks this:

 

$(document).ready(function () {
    $('#Field3').change(function () {
      var isDifferent = $('.isDifferent').find(':selected').val();
      var jobOne = $('.jobClassOne').find(':selected').val();
      var jobTwo = $('.jobClassTwo').find(':selected').val();
      	if(isDifferent == "No")
        {
          $('.jobClassTwo').val($('.jobClassOne').find(':selected').val()).attr("selected", "selected");
          //document.write("<p>Have a nice day!</p>");
        }      	
    });
});

 The document.write was only to be used to test if the branch was successful.

 

Edit:

The two fields that need to match are jobOne and jobTwo.

0 0

Answer

SELECTED ANSWER
replied on September 5, 2014

I figured it out after further testing.

 

$(document).ready(function () {
    $('#Field3').change(function () {
      var isDifferent = $('.isDifferent').find(':selected').val();
      var jobOne = $('.jobClassOne').find(':selected').val();
      var jobTwo = $('.jobClassTwo').find(':selected').val();
      	if(isDifferent == "No")
        {
          $('.jobClassTwo select').val(jobOne);
        }      	
    });
});

 

0 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.