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

Question

Question

How to check "other choice" check box control

asked on January 26, 2016

Hi,

I'm using Java to dynamically make at least one check box in a group required based on a selection from another radio button control. It works, except I can't figure out how to check the "other choice" check box since I can't assign it a value.

Any help/suggestions would be appreciated.

Ken

Here's if statement I am using:

 

if ($('input[type=Checkbox][value=AM1]:checked').length >0 ||
    $('input[type=Checkbox][value=AM2]:checked').length >0  ||
  	$('input[type=Checkbox][value=AM3]:checked').length >0  ||
    $('input[type=Checkbox][value=AM4]:checked').length >0  ||
    $('input[type=Checkbox][value=Other]:checked').length >0 )
        {
    		$('.amnotes input').removeAttr('required');
    		  
  		}
 			else
		{
    		$('.amnotes input').attr('required', 'True');
              
  		}

 

0 0

Replies

replied on January 26, 2016

From the looks of it, Forms is assigning the value "_other" to those checkboxes. That is how it is on my side:

1 0
replied on January 26, 2016

It worked! Wow you rock thanks!

1 0
replied on April 5, 2016 Show version history

Without looking at what the actual input classes are called, there is a bit of a problem with your jQuery selector. You need to precede "$('Field18_other_value input').val('Test');" with a "#" for an element with the id attribute set to "Field18_other_value" or with a "." for an element whose class is set to "Field18_other_value". I'm going to take a guess and say it is an id in which case your jQuery selector would be "$('#Field18_other_value input').val('Test');". Try that and let me know.

1 0
replied on January 26, 2016

Not entirely sure what you are asking, but I did get the part that you are trying to "check" the checkbox labeled "Other". If that is the case, you can use the following javascript to do so:

$('input:checkbox[value=Other]').prop('checked',true);

You may need to tweak the value to the specific value you gave the checkbox.

0 0
replied on January 26, 2016

Thanks for your reply. maybe if I include a screen shot for the form that would explain it better. So for the "Other" choice below, I'm not sure how to check when that item is selected because I can't assign a value to it like the choices 1-4. I tried looking for "Other" as seen in the script, but it is not working..

 

0 0
replied on January 30, 2016

That worked! Thanks

0 0
replied on April 5, 2016

Chris,

Your script above helped a ton.  Taking this a bit further, I would like to know how we can input a value in this 'Other' field.  I have the following code that is checking the box correctly, but no value is being added to the 'Other' input field.  

var value = $('.trans input').val();
    switch (value){
      case "1": 
			document.getElementById('Field18-0').checked = true;
          break;      
      case "10": 
			document.getElementById('Field18_other').checked = true;
			$('Field18_other_value input').val('Test');
          break;
      default:
};

Can you please tell me what I need to add to get a value entered in this box?  See Form below

Thanks,

Nate

0 0
replied on April 5, 2016

I would expect you could target it using:

$('#OtherField18').val('Text');

 

0 0
replied on April 5, 2016

I misread the below. Chris's answer below is spot on.

0 0
replied on April 5, 2016

That worked - I needed to take out the 'input' as well, but I got it to work.  Thanks for your help Chris!

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

Sign in to reply to this post.