2

I cannot seem to get the test in the 'Value' field

<input name="ctl00$PlaceHolderMain$ctl01$ctl12$ctl00$HiddenUserFieldValue" type="hidden" id="ctl00_PlaceHolderMain_ctl01_ctl12_ctl00_HiddenUserFieldValue" value="24;#Ryan,, C,#i:0#.f|membership|[email protected],#[email protected],#[email protected],#Ryan,, C">

How can get the data in the value field?

Thanks.. I know this should be easy but I'm about to shoot myself.

8
  • 1
    $("#ctl00_PlaceHolderMain_ctl01_ctl12_ctl00_HiddenUserFieldValue").val() Commented Mar 11, 2016 at 18:24
  • data value ? or just a value ? ? Commented Mar 11, 2016 at 18:25
  • #id must be lowercase, so that is the reason why you cannot get the value of the element by id. Commented Mar 11, 2016 at 18:28
  • 1
    What's going on there? Why such long values? Commented Mar 11, 2016 at 18:30
  • @HenryW That's not at all accurate... Commented Mar 11, 2016 at 18:30

2 Answers 2

1

Use the below code to fetch the element's value by id in jQuery. Check your output in console.

console.log($("#ctl00_PlaceHolderMain_ctl01_ctl12_ctl00_HiddenUserFieldValue").val());
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<input name="ctl00$PlaceHolderMain$ctl01$ctl12$ctl00$HiddenUserFieldValue" type="hidden" id="ctl00_PlaceHolderMain_ctl01_ctl12_ctl00_HiddenUserFieldValue" value="24;#Ryan,, C,#i:0#.f|membership|[email protected],#[email protected],#[email protected],#Ryan,, C">

Sign up to request clarification or add additional context in comments.

Comments

1

as id is there you should use # before the ID

var myval = $("#ctl00_PlaceHolderMain_ctl01_ctl12_ctl00_HiddenUserFieldValue").val();

4 Comments

Don't use alert as a debug statement, use console.log
Very true, or you could just follow typical debugging convention and be a good developer ;)
you can do anything, you can consol.log , you can use alert , you can store the value in any variable , but the thing is using this you got the value. am i right ?
try console logging an array, and alert()'ing the same array. It's not the same.

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.