0

I've created on onchange event handler using jQuery in SharePoint that is not working properly. After the page loads and the Request Type field is changed the other fields that are displayed will change on the fly based on the value selected from the drop-down menu.

This is the code that I am using that I can not for the life of me get to work and I even had a teacher who teaches jQuery look at it and she was not able to get it to work. Since I am very new to jQuery I am not too sure what I am doing wrong.

$(document).ready(function() {
    fieldload;

    $('select[title="Request Type"]').bind("change",function(){
    fieldload();
});
4
  • isn't bind() oldskool code and do you need change() ? Commented Jul 2, 2016 at 9:34
  • I'm using an older version of JQuery that is why I used .bind Commented Jul 3, 2016 at 7:57
  • why are you using older versions when there are lot depreciated methods there?
    – user13408
    Commented Jul 3, 2016 at 15:53
  • long story short I am blocked from downloading anything on my computer and it disables any external drive that is plugged into it. So I use what I inherited from the last person that had my job. Commented Jul 4, 2016 at 1:45

1 Answer 1

0

Correct code should be

$('select[title="Request Type"]').on('change', function() {
    alert(this.value); // or $(this).val()
});

Or if you directly want to get selected value use:

alert($(this).find(":selected").val());
1
  • with the above code, the browser displays the following error message: Message from webpage with an exclamation mark and the selected field name. Not sure how t fix this Commented Jul 3, 2016 at 7:34

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.