(Reprinted) How to Use js to get the textbox value in Asp.net. js cannot get the text value
<Tr>
<TD class = "table_body" style = "width: 10%" align = "right">
Work Objectives
</TD>
<TD class = "table_none" style = "width: 90%" colspan = "2">
<Asp: textbox id = "txt_jobgoal" runat = "server" width = "100%" textmode = "multiline" tooltip = "Enter the work target! "> </ASP: textbox>
</TD>
</Tr>
// The javascript statement is as follows:
<Script language = "JavaScript" type = "text/JavaScript">
Function whetherempty ()
{
// Alert ("the KPI information cannot be blank! ");
Emptflag = false;
VaR jobgoal = Document. getelementbyid ("txt_jobgoal"). value;
}
</SCRIPT>
The value in the text control cannot be obtained! Set breakpoints. In The Real-Time Window, check that the value of document. getelementbyid ("txt_jobgoal") is null. When running, a message similar to the following is displayed: Document. getelementbyid () is not an object or the value is null!
Cause: the client ID is changed when textbox generates HTML. A lot of prefixes are added before txt_jobgoal.
Rewrite the JavaScript Functions on the page as follows:
<Script language = "JavaScript" type = "text/JavaScript">
Function whetherempty ()
{
// Alert ("the KPI information cannot be blank! ");
Emptflag = false;
VaR jobgoal = Document. getelementbyid ("<% = txt_jobgoal.clientid %>"). value;
}
</SCRIPT>
This article is from the csdn blog. For more information, see the source:Http://blog.csdn.net/sire168/archive/2010/06/22/5686041.aspx
(Reprinted) How to Use js to get the textbox value in Asp.net. js cannot get the text value
<Tr>
<TD class = "table_body" style = "width: 10%" align = "right">
Work Objectives
</TD>
<TD class = "table_none" style = "width: 90%" colspan = "2">
<Asp: textbox id = "txt_jobgoal" runat = "server" width = "100%" textmode = "multiline" tooltip = "Enter the work target! "> </ASP: textbox>
</TD>
</Tr>
// The javascript statement is as follows:
<Script language = "JavaScript" type = "text/JavaScript">
Function whetherempty ()
{
// Alert ("the KPI information cannot be blank! ");
Emptflag = false;
VaR jobgoal = Document. getelementbyid ("txt_jobgoal"). value;
}
</SCRIPT>
The value in the text control cannot be obtained! Set breakpoints. In The Real-Time Window, check that the value of document. getelementbyid ("txt_jobgoal") is null. When running, a message similar to the following is displayed: Document. getelementbyid () is not an object or the value is null!
Cause: the client ID is changed when textbox generates HTML. A lot of prefixes are added before txt_jobgoal.
Rewrite the JavaScript Functions on the page as follows:
<Script language = "JavaScript" type = "text/JavaScript">
Function whetherempty ()
{
// Alert ("the KPI information cannot be blank! ");
Emptflag = false;
VaR jobgoal = Document. getelementbyid ("<% = txt_jobgoal.clientid %>"). value;
}
</SCRIPT>
This article is from the csdn blog. For more information, see the source:Http://blog.csdn.net/sire168/archive/2010/06/22/5686041.aspx