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

Question

Question

change radio text

asked on September 2, 2016 Show version history

I have a several radio button objects:

depending on the selections in 1 and 2, the dollar amount needs to be reflected in the options of 3.

For example, if radio 1 (#q52) is Enroll and radio 2 (#q53) is EnrollBasic, then the text of radio 3 (#q54) options would be:

        "Employee Only ($7)"
        "Employee/Spouse ($17)"
        "Employee/Child ($24)"
        "Employee/Children ($35)"
        "Employee/Family ($43)"

What would be the jquery code to change the labels for each option in #q54?

0 0

Replies

replied on September 8, 2016

This is the correct syntax to change the labels:

I used this to trap for the button selection:

1 0
replied on September 6, 2016 Show version history

Maybe below javascript could provide you some thoughts.

$("#q52, #q53 input").on('change', function(){
  if ($("#q52 input:checked").val() == "Enroll in Wellness Premium Discount" && $("#q53 input:checked").val() == "Enroll in Basic Medical Coverage") {
      // The corresponding choices.
      $($('#q54 label')[1]).text("Employee Only ($7)");
      $($('#q54 label')[2]).text("Employee/Spouse ($17)");
      $($('#q54 label')[3]).text("Employee/Child ($24)");
      $($('#q54 label')[4]).text("Employee/Children ($35)");
      $($('#q54 label')[5]).text("Employee/Family ($43)");
  } else {
      // The default choices.
      $($('#q54 label')[1]).text("Employee Only");
      $($('#q54 label')[2]).text("Employee/Spouse");
      $($('#q54 label')[3]).text("Employee/Child");
      $($('#q54 label')[4]).text("Employee/Children");
      $($('#q54 label')[5]).text("Employee/Family");
  }
});

 

0 0
replied on September 6, 2016

Hello Mary, 

here is something you could try:

$("#q52, #q53 input").on('change', function(){
var amount1 = 7;  
var amount2 = 17;  
var amount3 = 24;  
var amount4 = 35;  
var amount5 = 43;
  
var empOnly = "Employee Only ($" + amount1 + ")";
var empSpouse = "Employee/Spouse ($" + amount2 + ")";
var empChild = "Employee/Child ($" + amount3 + ")";
var empChildren = "Employee/Children ($" + amount4 + ")";
var empFamily = "Employee/Family ($" + amount5 + ")";
  
  $('label[for="Field54-0"]').contents().last()[0].textContent=empOnly;
  $('label[for="Field54-1"]').contents().last()[0].textContent=empSpouse;
  $('label[for="Field54-2"]').contents().last()[0].textContent=empChild;
  $('label[for="Field54-3"]').contents().last()[0].textContent=empChildren;
  $('label[for="Field54-4"]').contents().last()[0].textContent=empFamily;
  
});

 

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

Sign in to reply to this post.