0

I need to get fieldValues of radio buttons i have successful got it from textareas and from dropdown

To get it for textareas and dropdown i used this way:

$('#GEN_1').val(item.get_fieldValues().GEN_1_Sum_Scope_Assigment);

and i tried to get it from radio button this way:

$('input[name="GEN20"]:checked').val(item.get_fieldValues().GEN_20_EL);
$('#GEN_20 input[name="GEN20"]').val(item.get_fieldValues().GEN_20_EL);  
$('#GEN_20 input[name="GEN20"]:checked').val(item.get_fieldValues().GEN_20_EL);

HTML for radio button

<input id="GEN_20_1" type="radio" name="GEN20" value="1">Ja
<br />
<input id="GEN_20_2" type="radio" name="GEN20" value="0">Nej

How can i do it?

My other question to know more what I'm doing:

Load list item to dispaly get_fieldValues?

Update

I want it to set the "black dot" in the one that is checked when i get the value

enter image description here

3
  • Can you update your question with HTML code of Radio Buttons Commented Oct 30, 2014 at 12:18
  • I have updated it now Commented Oct 30, 2014 at 12:20
  • I have updated my answer Commented Oct 30, 2014 at 12:39

1 Answer 1

1

Try below

$("input[name=GEN20][value=" + item.get_fieldValues().GEN_20_EL == false ? 0 : 1 + "]").attr('checked', 'checked');

//OR

$("input[name=GEN20][value=" + item.get_fieldValues().GEN_20_EL == false ? 0 : 1 + "]").prop('checked', 'checked');

Another option

if(item.get_fieldValues().GEN_20_EL == true) {
    $('#GEN_20_1').attr('checked','checked');
}
else
    $('#GEN_20_2').attr('checked','checked');
5
  • Tested but neiter worked going to update mu question to let you know more what i want Commented Oct 30, 2014 at 12:31
  • Put an alert statement to display what value comes for item.get_fieldValues().GEN_20_EL Commented Oct 30, 2014 at 12:32
  • i get false and it is set to false(No) but why will it not show "the black dot"? Commented Oct 30, 2014 at 12:39
  • Because the radio button value is "1" and "0". Hence setting its not working. I have updated my code to handle that Commented Oct 30, 2014 at 12:41
  • i haven't tried your new answers but just letting you know that i still got false but it set to yes going to try your new way know Commented Oct 30, 2014 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.