Technique//post instead of form<script language= "VBScript" >
Function urlencoding (Vstrin)
Strreturn = ""
For i = 1 to Len (Vstrin)
THISCHR = Mid (vstrin,i,1)
If Abs (ASC (THISCHR)) < &hff Then
Strreturn = Strreturn & THISCHR
Else
Innercode = ASC (THISCHR)
If Innercode < 0 Then
Innercode = Innercode + &h10000
End If
Hight8 = (Innercode and &hff00) \ &hff
Low8 = Innercode and &hff
Strreturn = strreturn & "%" & Hex (HIGHT8) & "%" & Hex (LOW8)
End If
Next
urlencoding = Strreturn
End Function
Function Bytes2bstr (vIn)
Strreturn = ""
For i = 1 to LenB (vIn)
Thischarcode = AscB (MidB (vin,i,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = AscB (MidB (vin,i+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
i = i + 1
End If
Next
Bytes2bstr = Strreturn
End Function
Dim stra,oreq
Stra = urlencoding ("submit1=submit&text1= Chinese")
Set oreq = CreateObject ("MSXML2. XMLHTTP ")
Oreq.open "POST", "http://ServerName/VDir/TstResult.asp", False
Oreq.setrequestheader "Content-length", Len (Stra)
Oreq.setrequestheader "Content-type", "application/x-www-form-urlencoded"
Oreq.send Stra
MsgBox Bytes2bstr (oreq.responsebody)
</SCRIPT>
ReadyState is the progress of the XMLHTTP return data, 0 = load, 1 = uninitialized, 2 = loaded, 3 = run, 4 = complete
//component is installed
IsComponentInstalled ("{6b053a4b-a7ec-4d3d-4567-b8ff8a1a5739}", "ComponentID"))
//Check whether the page exists
function Checkurl (URL)
{
var xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP");
xmlHTTP. Open ("Get", URL, false);
Try
{
xmlHTTP. Send ();
var result = Xmlhttp.status;
}
catch (E) {return (false);}
if (result==200)
{
return true;
}
XMLHTTP = null;
return false;
}//Connection database
<script language= "JavaScript" >
code example for using JavaScript to write server-side connection databases
var conn = new ActiveXObject ("ADODB. Connection ");
Conn. Open ("Provider=SQLOLEDB.1; Data Source=localhost; User Id=sa; "
+ "password=; Initial catalog=pubs ");
var rs = new ActiveXObject ("ADODB. Recordset ");
var sql= "SELECT * from authors";
Rs.Open (SQL, conn);
shtml = "<table width= ' 100% ' border=1>";
shtml = "<tr bgcolor= ' #f4f4f4 ' ><td>au_id</td><td>au_lname</td><td>au_fname </td><td>phone</td><td>address</td><td> city</td><td>state</ Td><td>zip</td></tr> ";
while (!rs. EOF)
{
sHTML + + "<tr><td>" + RS ("au_id") + "</td><td>" + RS ("au_lname") + "</td><td>" + RS ("a U_fname ") +" </td><td> "+ RS (" phone ") +" </td><td> "+ RS (" address ") +" </td><td> "+ RS ("City") + "</td><td>" + RS ("state") + "</td><td>" + RS ("zip") + "</td></tr>";
Rs.movenext;
}
sHTML = "</table>";
document.write (shtml);
Rs.close ();
rs = null;
Conn.close ();
conn = null;
</script>
//Use of data island
<body>
Srno:<input type=text datasrc= #xmldate datafld=srno size= "><BR>"
Times:<input type=text datasrc= #xmldate datafld=times size= "><BR>"
<input id= "First" Type=button value= "<< record" >
<input id= "prev" Type=button value= "< previous record" >
<input id= "Next" Type=button value= "next Record >" >
<input id= "Last" Type=button value= "final record >>" >
<input id= "Add" Type=button value= "adding new Record" >
<xml id= "Xmldate" >
<infolist>
<info ><srno>20041025-01</srno><times>null</times></info>
<info ><srno>20041101-09</srno><times>2004 Year October 1 2:22 0 sec </times></info>
</infolist>
</XML>
</body>
//Get Parameters <body>
<a href= "Javascript:location.href=location.href + '? a=1&b=2 '" >search</a>
<script language= "JavaScript" >
<!--
var a = location.search.substr (1);
if (a.length>0)
{
var re =/([^&]*?) \= ([^&]*)/g
var s = a.match (re);
for (var i= 0;i<s.length;i++)
{
Alert (S[i]);
Alert (s[i].split ("=") [1]);
}
}
-->
</script>
</body>
//Editable Select <input type=text name=re_name style= "WIDTH:100PX;HEIGHT:21PX;" font-size:10pt; " ><span style= "width:18px;border:0px solid red;" ><select name= "r00" style= "Margin-left:-100px;width:118px; background-color: #FFEEEE;" >
<option value= "1" >11111111<option>
<option value= "2" >222222</option>
<option value= "3" >333333</option>
</select>
</span>