0

in My custom form i have my HTMl like this

  <td width="400px" valign="top" class="ms-formbody" id="Type_x0020_of_x0020_Request"><span dir="none"><select name="ctl00$ctl33$g_ad15cfef_4ccd_4d9f_8ab2_ed089bcb96c6$ff81$ctl00$DropDownChoice" id="ctl00_ctl33_g_ad15cfef_4ccd_4d9f_8ab2_ed089bcb96c6_ff81_ctl00_DropDownChoice" title="Type of Request" class="ms-RadioText">
                        <option selected="selected" value="Please Select">Please Select</option>
                        <option value="508 Remediation for BPHC Website">508 Remediation for BPHC Website</option>
                        <option value="Graphic Design">Graphic Design</option>
                        <option value="Presentation Development">Presentation Development</option>
                        <option value="Speakers Bureau">Speakers Bureau</option>
                        <option value="Webinar (Adobe Connect Assistance)">Webinar (Adobe Connect Assistance)</option>
                        <option value="BPHC Website">BPHC Website</option>
                        <option value="Writing/Editing">Writing/Editing</option>

                    </select><br></span></td>

How can i select the Dropdown and trigger chnage event based on the ID "Type_x0020_of_x0020_Request" ? I tried like this but change event is not working

$('#Type_x0020_of_x0020_Request span select').change(function () {

            typeOfRequestvalue = $(this).find("option:selected").text();
            alert(typeOfRequestvalue);
    });

1 Answer 1

0

The id "Type_x0020_of_x0020_Request" is for the <td> element not <select> element (drop down list).

The id of your drop down list - <select> element is ctl00_ctl33_g_ad15cfef_4ccd_4d9f_8ab2_ed089bcb96c6_ff81_ctl00_DropDownChoice.

You cannot get the selected option value from the <td> element.

And the change event only works on <input>, <textarea> and <select> elements.

Use script below:

<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript"> 
$(document).ready(function(){
    //by title
    $("select[title='Type of Request'").change(function(){
       var selected = $(this).find("option:selected").text();
       alert(selected);
    });
    //by id
    $("select[id='ctl00_ctl33_g_ad15cfef_4ccd_4d9f_8ab2_ed089bcb96c6_ff81_ctl00_DropDownChoice'").change(function(){
       var typeOfRequestvalue = $(this).find("option:selected").text();
       alert(typeOfRequestvalue);
    });
});
</script>

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.