1

I have Choice Field which i use to filter items within a list. I'm trying to figure out a way to set value of this choice field within my edit form is there is a name in the people picker field.

This is my form: enter image description here What I'm trying to do is when a NAPA User is selected (any user) the status goes from New to In Progress.

This is what the choice field looks like in consol:

<select name="ctl00$m$g_0537f4e9_69aa_409a_b5ed_15e3624efeab$ctl00$ctl05$ctl01$ctl00$ctl00$ctl04$ctl00$DropDownChoice" id="ctl00_m_g_0537f4e9_69aa_409a_b5ed_15e3624efeab_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_DropDownChoice" class="ms-RadioText">
    <option selected="selected" value="1. New">1. New</option>
    <option value="2. In-Progress">2. In-Progress</option>
    <option value="3. Completed">3. Completed</option>
    <option value="4. Cancelled">4. Cancelled</option>
</select>

I got these ID's also:

people picker ID: <div id="ctl00_m_g_0537f4e9_69aa_409a_b5ed_15e3624efeab_ctl00_ctl05_ctl03_ctl00_ctl00_ctl04_ctl00_ctl00_UserField_upLevelDiv" 

$("[id$=UserField_upLevelDiv]")

status ID: id="ctl00_m_g_0537f4e9_69aa_409a_b5ed_15e3624efeab_ctl00_ctl05_ctl01_ctl00_ctl00_ctl04_ctl00_DropDownChoice" 

$("[id$=DropDownChoice]")

I just don't know how to write an if statement that would read like:

if [$("[id$=UserField_upLevelDiv]")> 0]{
      set.$("[id$=DropDownChoice]").value = 2
}
1

Add content editor web part on newform.aspx page and write jquery ready function and add below code.

ex:

<script language="javascript" type="text/javascript">
$(document).ready(function() {  
$("select[title='Status']").val('2. In-Progress');
});
</script>

**for geting current value :** <br><br>

var mySelectValue = $("select[title='My Choice']").val();


**for setting Choice value :**<br><br>

$("select[title='My Choice']").val('2. In-Progress');

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.