Tuesday, May 28, 2024
 Popular · Latest · Hot · Upcoming
63
rated 0 times [  67] [ 4]  / answers: 1 / hits: 31109  / 13 Years ago, fri, may 20, 2011, 12:00:00

I dont know why my script is not working. I tried to get value of textbox in javascript but its not giving me a value. Value is shown as null.



//This is the code for my textbox

<td> <input id=demo3 type=text size=25 runat=server/><a href=javascript:NewCal('demo3','ddmmmyyyy',true,24)>
<img src=Resources/cal.gif width=16 height=16 border=0 alt=Pick a date></a> </td>

//This is how I trid to access textbox
exDateTime = document.getElementById('pCtrl').value;


but exDateTime is remains null.
I tried using other ways too, but nothing seen happening..


More From » javascript

 Answers
117

I don't think you are referring to the proper id.
Try document.getElementById(demo3).value



Or atleast paste the code where your pCtrl form field is.



EDIT : Make sure you set the value for the text box in html or using Javascript for example:



<input type='text' id='demo3' value='3'> 


and then use document.getElementById(demo3).value to get the value, otherwise use javascript to assign the value and obtain the value at a later stage using the same.



I hope this helped you.


[#92142] Wednesday, May 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
blaisep

Total Points: 748
Total Questions: 95
Total Answers: 108

Location: Federated States of Micronesia
Member since Sun, May 16, 2021
3 Years ago
blaisep questions
Wed, Dec 16, 20, 00:00, 4 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
Tue, Nov 12, 19, 00:00, 5 Years ago
Mon, Nov 11, 19, 00:00, 5 Years ago
;