开发者

To get value of textbox in javascript

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="开发者_C百科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..


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.


I bet this is a .net issue

Try this:

<input id="demo3" type="text" size="25" runat="server"/><a 
href="#" onclick="NewCal('<%= demo3.ClientID %>','ddmmmyyyy',true,24); 
return false"><img src="Resources/cal.gif" width="16" height="16" border="0" 
alt="Pick a date"></a>   


exDateTime = document.getElementById('<%= demo3.ClientID %>').value;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜