0

In my list I added Choice control. In this control I add multiple values I want set predefined using jQuery.

Please check attachment. I want to when page load that two check boxes are selected automatically.

$("input[id^='Product1_'][id*='_MultiChoiceOption_']").each(function(){         
////
});

enter image description here

| improve this question | | | | |
2

You can use following code for your requirements:

    jQuery(function(){
      jQuery("span.ms-RadioText[title='Education'] input[type=checkbox]").attr("checked", "checked");
      jQuery("span.ms-RadioText[title='Retail'] input[type=checkbox]").attr("checked", "checked");
    })  

Selector span.ms-RadioText[title='Education'] input[type=checkbox] selects your particular checkbox by using checkbox value.

| improve this answer | | | | |
  • Hey thanks for reply this is my loop how to select in this loop only Retail and Edu $("input[id^='Product1_'][id*='MultiChoiceOption']").each(function(){ alert("hi")}); – Admin Nov 23 '16 at 8:28
  • You don't need loop for this, just use selectors I proposed. – Sergei Sergeev Nov 23 '16 at 8:32
1

Yes , you can achecive this using placing below jquery in document.ready function

This multiple chocie control renders in the below format , so you can find the id of the particular option you want to check it by default.

<input id="Vertical_a8554df1-914b-483a-9ebd-43c92c17ad03_MultiChoiceOption_5" type="checkbox">
<label for="PRID_a8554df1-914b-483a-9ebd-43c92c17ad03_MultiChoiceOption_5">Education</label>

//put this in document.ready function
//This you can use to checkthe specific checkbox using its id
$('#Vertical_a8554df1-914b-483a-9ebd-43c92c17ad03_MultiChoiceOption_5').prop("checked", true);
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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