0

I've added the following code into a CEWP part at the top of the Editform.aspx page (using SharePoint 2013)

<html>
<script src="https://oursites/jquery-1.11.3.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var s1 = $("select[title = 'Request ID']");
        alert(s1);
        var s2 = s1.val();
        alert(s2);
        var s3 = $("select[title = 'Request ID']").val();
        alert(s3);
        var s4 = $("select[title = 'Request ID']").text();
        alert(s4);
        var text = $("select[title$='Request ID'] :selected").text();
        alert(text);

    });

</script>
</html>

However, I am unable to retrieve the field value.

The results of the alerts are:
S1 [object Object]
S2 undefined
S3 undefined
S4 -empty alert window-
text -empty alert window-

My aim is to use values from the form to hide columns. The hide function works fine, but I just can't access the form values. What have I done wrong? Thanks!

SOLVED:

The code had to be

var s3 = $("input[title='Request ID']").val();

If any newbies (like me) see this post, check out this website

http://geekswithblogs.net/SoYouKnow/archive/2011/07/28/a-dummies-guide-to-sharepoint-and-jqueryndashgetting-started.aspx

  • Please remember to post your solution as an actual answer as soon as you are able to do that – Robert Lindgren Jul 2 '15 at 5:40
0

SOLVED:

The code had to be

var s3 = $("input[title='Request ID']").val();

If any newbies (like me) see this post, check out this website

http://geekswithblogs.net/SoYouKnow/archive/2011/07/28/a-dummies-guide-to-sharepoint-and-jqueryndashgetting-started.aspx

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.