0

Im hoping someone could supply me the proper SHAREPOINT SYNTAX to use in JQUERY code to check what the value of a SHAREPPOIINT CHOICE TYPE field.

I thought I needed to check a checkbox type field so I started with:

 if ($("input[title$='Phone Data Collection']").is(':checked'))

...and looked for a change event with...

 $("input[title$='Phone Data Collection']").click(function()

{

    //If checkbox is checked then hide the fields

    if (this.checked)

But now that I know it is a SHAREPOINT CHOICE TYPE field I'm a little lost. I'm not returning the SHAREPOINT CHOICE TYPE field value and I don't know who to trigger the SHAREPOINT CHOICE TYPE field change event. Please help...

1
  • 1
    Just because this is in SharePoint, doesn't mean it doesn't behave like normal html/javascript. Because of that fact, the question is not a SharePoint question, but one regarding javascript/jQuery, and is therefore off-topic. Use F12 to bring up developer tools, and you should be able to figure this out yourself.
    – wjervis
    Commented Jun 22, 2016 at 18:02

1 Answer 1

2

The below will return you the current value of the select field:

$("select[title$='Phone Data Collection']").val()

To put it as part of your logic you would do:

if ( $("select[title$='Phone Data Collection']").val() =='SOME VALUE')
6
  • Will this capture the event like: $("input[title$='Phone Data Collection']").click(function()
    – John
    Commented Jun 21, 2016 at 23:55
  • What I mean is that I'm not triggering that function where I check to see the value of the choice. the function should run when the choice radio button is clicked, right?
    – John
    Commented Jun 22, 2016 at 0:02
  • And when I do: alert ('pdc is ' + $("[title='Phone Data Collection']").val()) the value is undefined. Please assist.
    – John
    Commented Jun 22, 2016 at 0:18
  • it should be like this $("select[title$='Phone Data Collection']").val() Commented Jun 22, 2016 at 9:14
  • Thank you Ankit but I'm still getting undefined for the value. $(document).ready(function() { alert('onload'); alert ('pdc is ' + $("select[title$='Phone Data Collection']").val()) //Hides /Shows Fields on load? if ( $("[title='Phone Data Collection']").val() =='Yes') { alert('inside show for phone');
    – John
    Commented Jun 22, 2016 at 14:30

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.