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

Question

Question

Checkbox Values in Fields

asked on September 12, 2017 Show version history

I have the following JavaScript that works beautifully:

$(document).ready(function(){
//Teams Fill Based on What's Checked
  $(".dcrReviewList").change(function () { 
    if ($("input[id^=Field169-0]").is(':checked'))
    {
      $('.draftingTeam input').val("Drafting and Design");
    }
    else
    {
      $('.draftingTeam input').val("");        
    }
  })
});  //close document.ready

The problem is that I now want to also do this for Nuclear Analysis, QA Project Support, Structural Analysis, and Thermal Analysis. If someone could guide me for Nuclear Analysis, I can figure out the rest.

I will eventually use this to create a Lookup based on the team. Thanks in advance!

0 0

Answer

SELECTED ANSWER
replied on September 12, 2017 Show version history

Hi Gloria,

Here you are:

$(document).ready(function(){
//Teams Fill Based on What's Checked
  $(".dcrReviewList").change(function () { 
    if ($("input[id^=Field169-0]").is(':checked'))
    {
      $('.draftingTeam input').val("Drafting and Design");
    }
    else
    {
      $('.draftingTeam input').val("");        
    }
    
    if ($("input[id^=Field169-1]").is(':checked'))
    {
      $('.nuclearTeam input').val("Nuclear Analysis");
    }
    else
    {
      $('.nuclearTeam input').val("");        
    }
  })
});  //close document.ready

Follows the same logic as the condition in your JavaScript for the drafting team. Only things to add are the CSS classes to each of your hidden fields (.nuclearTeam, .qaTeam, etc).

About this line:

 if ($("input[id^=Field169-1]").is(':checked'))

The "Field169-1" is an ID you can find from your preview page by right-clicking on an element and hitting Inspect. For me it was Field1-1 for the Nuclear Analysis checkbox:

 

 

1 0
replied on September 12, 2017

Thanks! I was so close! I tried an "else if" which obviously didn't work. Didn't realize I could do another "if" statement again for the next checkbox. Appreciate the help!

1 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.