The function I want to complete is to replace the carriage return linefeed (\ r \ n) in the multi-line text box with a comma (,).
UseVaRS=Document. All ('Textboxdata'). Value to obtain its value,ProgramWork properly, but use$ ("# Textboxdata"). Val ()The program does not work properly when obtaining the value.
Puzzling, depressing...
HTML code
< Script SRC = "../JS/jquery. Pack. js" Type = "Text/JavaScript" > </ Script >
< Script SRC = "../JS/jquery-1.2.6-vsdoc.js" Type = "Text/JavaScript" > </ Script >
< Script Type = "Text/JavaScript" Language = "JavaScript" >
$ ( Function (){
$ ( " A " ). Focus ( Function (){ This . Blur ();});
$ ( " # Btncancel " ). Click ( Function () {Window. Close ();});
$ ( " # Btnok " ). Click ( Function ()
{
VaR Values = $. Trim ($ ( " # Textboxdata " ). Val ());
If (Values. Length = 0 )
{
Window. Alert ( " Note: You have not entered any items. If you discard the input, click "cancel ". " );
Return False ;
}
Else
{
VaR S = Document. All ( ' Textboxdata ' ). Value; // If var S = values is used, \ r \ n --> "," cannot be replaced! $ ("# Textboxdata"). Val () is how to obtain the value in textarea?
S = S. Replace ( / \ R \ n / G, " , " );
Window. returnvalue = S;
Window. Close ();
}
Return False ;
});
});
</ Script >
< Form ID = "Form1" Runat = "Server" >
< Div Style = "Width: 99%" >
< Div Style = "Padding: 10px; text-align: Center" >
< ASP: textbox ID = "Textboxdata" Runat = "Server" Height = "300px" Width = "100%" Textmode = "Multiline" > </ ASP: textbox > </ Div >
< Div Style = "Padding: 20px; text-align: Center" > < ASP: button ID = "Btnok" Runat = "Server" Text = "OK" Width = "60px" > < ASP: button ID = "Btncancel" Runat = "Server" Text = "Cancel" Width = "60px" > </ ASP: button > </ ASP: button > </ Div >
< Div > Note: Enter the values of multiple rows in a single column in the text box. </ Div >
</ Div >
</ Form>