Page:
<SCRIPT type = "text/JavaScript">
// Create an Ajax object
VaR Ajax = new function ()
{
This. _ url = "updatesimilarity! Updatesimilarity. Action ";
// Create an XMLHTTPRequest object
This. createxmlhttp = function (){
VaR XMLHTTP = NULL;
// Use different creation methods based on whether the window. XMLHTTPRequest object exists
If (window. XMLHttpRequest ){
XMLHTTP = new XMLHttpRequest ();
} Else if (window. activexobject ){
XMLHTTP = new activexobject ("Microsoft. XMLHTTP ");
} Else if (window. activexobject ){
XMLHTTP = new activexobject ("msxml2.xmlhttp. 4.0 ");
} Else if (window. activexobject ){
XMLHTTP = new activexobject ("msxml2.xmlhttp ");
}
Return XMLHTTP;
}
// Modify the similarity
This. updatesimilarity = function (rownum)
{
VaR rownum = rownum;
VaR similarity = Document. getelementbyid ("similarity" + rownum). value. Trim (); // The value of the text box
VaR keywordscategid = Document. getelementbyid ("keywordscategid" + rownum). value. Trim ();
VaR actiontype = Document. getelementbyid ("actiontype" + rownum). value. Trim ();
Res =/^ ([1-9] [0-9] * | 0) $ /;
If (similarity = ""){
Alert ("similarity cannot be blank! ");
Document. getelementbyid ("similarity" + rownum). Focus ();
Return false;
}
If (! (Res. Test (similarity ))){
Alert ("similarity, please enter a positive integer, cannot contain special characters! ");
Document. getelementbyid ("similarity" + rownum). Focus ();
Return false;
}
VaR XMLHTTP = This. createxmlhttp (); // create an XMLHTTPRequest object
XMLHTTP. onreadystatechange = function ()
{
If (XMLHTTP. readystate = 4)
{
If (XMLHTTP. Status = 200 ){
Alert ("modified successfully! ");
Window. Parent. frames. Mainframe. Location. Reload ();
} Else {
Alert ("server fault ");
}
}
}
VaR url = This. _ URL + "? Similarity = "+ similarity +" & keywordscategid = "+ keywordscategid +" & actiontype = "+ actiontype;
XMLHTTP. Open ("get", encodeuri (URL), true );
XMLHTTP. Send (null );
}
}
</SCRIPT>
<Input type = "text" name = "similarity" id = "similarity <% = J %>" value = "<s: property value = "similarity"/> "size =" 3 "maxlength =" 3 "class =" biaoti2 "/>
<A href = "#" onclick = "Ajax. updatesimilarity (<% = J %>);"> modify </a>