Figure 1
Checkboxes
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<input type=checkbox id='BUNode' onclick="selected()" >
<script>
// Once you have viewed the page, refresh
//uncomment the next line then do a refresh...
//var y = new ActiveXObject("Scripting.Dictionary");
var i;
for ( i=0;i < document.all.item("BUNode").length; i++ )
{
document.all.item("BUNode").item(i).checked = true;
}
</script>
Figure 2 Call init in Onload <html>
<head>
<script language="javascript">
var y = new ActiveXObject("Scripting.Dictionary");
function init() {
var i;
for ( i=0;i < document.all.item("BUNode").length; i++ )
{
document.all.item("BUNode").item(i).checked = true;
}
alert ("done");
}
</script>
</head>
<body onload="init();">
<!-- your <input> definitions would go here -->
</body>
</html>
Figure 4 Calling .js Files <HTML>
<BODY BGCOLOR="#FFFFFF" topmargin=0 leftmargin=0>
<script language="JavaScript" src="toolbar.js"></script>
<script language="JavaScript" src="global.js"></script>
<script language="JavaScript" src="local.js"></script>
<script language="JavaScript">
<!--// Hide from old browsers
var ToolBar_Supported = ToolBar_Supported;
if (ToolBar_Supported != null && ToolBar_Supported == true)
{
setAds('/library/homepage/images/banner_25th.gif',
'/museum/anniversary.asp', 'Microsoft 25th Anniversary');
drawToolbar();
}
//-->
</script>
</BODY>
</HTML>
Figure 5 DeQuoter function DeQuote (str)
tmpStr = str
Do While InStr (tmpStr, "'")
DeQuote = DeQuote & Left(tmpStr, InStr(tmpStr, "'")-1) & "''"
tmpStr = Right(tmpStr, len(tmpStr)-InStr(tmpStr, "'"))
Loop
if len(tmpStr) > 0 then DeQuote = DeQuote & tmpStr
DeQuote = LTrim(DeQuote)
DeQuote = RTrim(DeQuote)
if len(DeQuote)<=0 then DeQuote=" "
end function
Figure 6 DeQuote, Convert Carriage Returns, and Update <%@ LANGUAGE="VBSCRIPT"%>
<html>
<%
function DeQuote (str)
tmpStr = str
Do While InStr (tmpStr, "'")
DeQuote = DeQuote & Left(tmpStr, InStr(tmpStr, "'")-1) & "''"
tmpStr = Right(tmpStr, len(tmpStr)-InStr(tmpStr, "'"))
Loop
if len(tmpStr) > 0 then DeQuote = DeQuote & tmpStr
DeQuote = LTrim(DeQuote)
DeQuote = RTrim(DeQuote)
if len(DeQuote)<=0 then DeQuote=" "
end function
function ReWrap (str)
tmpStr = str
Do While InStr (tmpStr, vbCRLF)
ReWrap = ReWrap & Left(tmpStr, InStr(tmpStr, vbCRLF)-1) & "<br>"
tmpStr = Right(tmpStr, len(tmpStr)-InStr(tmpStr, vbCRLF))
Loop
if len(tmpStr) > 0 then ReWrap = ReWrap & tmpStr
ReWrap = Trim(ReWrap)
end function
%>
<body bgcolor=white>
<form>
<textarea id="information" name="information" rows=5 cols=50
onkeyup="report1.innerHTML=information.value;report2.innerText=information.value">
</textarea><br>
<input type=submit value="Submit to Database">
</form>
<table cellspacing=0>
<tr><td bgcolor=black><font size=1 face=verdana color=white>When displayed using .innerHTML:</font></td></tr>
<tr><td bgcolor=beige id=report1>(nothing entered yet)</td></tr>
<tr><td bgcolor=black><font size=1 face=verdana color=white>When displayed using .innerText</font></td></tr>
<tr><td bgcolor=beige id=report2>(nothing entered yet)</td></tr>
</table>
<br>
<%
infoIn = Request("information")
infoOut = infoIn
if len(infoIn) > 0 then
' Build up the connection string:
dbFile = "test.mdb"
dbTable = "Table1"
path = Server.mapPath (dbFile)
DB = "DBQ=" & path & ";Driver={Microsoft Access Driver (*.mdb)};"
Set Conn = Server.CreateObject("ADODB.Connection")
' Open the database:
Conn.Open DB
' Assumption, is that the database has a table named "Table1",
' with at least two fields, one "id" which is of type AutoNumber,
' and a second named "MemoField" which is of type "memo",
' and that at least one record has been stored in this database
' which the following code will simply overwrite.
' Create an ADO recordset:
Set cmdTemp = Server.CreateObject("ADODB.Command")
Set DataCommand1 = Server.CreateObject("ADODB.Recordset")
Query = "SELECT * FROM " & dbTable
Set RS_item = Conn.Execute(Query)
' Update the "MemoField" of the first record to contain
' the incoming text field.
Query = "UPDATE " & dbTable & " SET "
Query = Query & "MemoField= '" & DeQuote(infoIn) & "'"
Query = Query & " WHERE (id = " & RS_Item("ID") & ")"
Conn.Execute(Query)
' No read back "MemoField" from the database just
' so we can verify its contents:
Query = "SELECT * FROM " & dbTable
Set RS_item = Conn.Execute(Query)
infoOut = RS_item("MemoField")
' We're done with the database now, so close it
Conn.Close
' Now report:
response.write ("<table cellspacing=0>")
response.write ("<tr><td bgcolor=black>")
response.write ("<font size=1 face=verdana color=white>As submitted:
</font>")
response.write ("</td></tr><tr><td bgcolor=beige>")
response.write (infoIn)
response.write ("</td></tr><tr><td bgcolor=black>")
response.write ("<font size=1 face=verdana color=white>As returned from
the database:</font>")
response.write ("</td></tr><tr><td bgcolor=beige>")
response.write (infoOut)
response.write ("</td></tr><tr><td bgcolor=black>")
response.write ("<font size=1 face=verdana color=white>As corrected via
ReWrap:</font>")
response.write ("</td></tr><tr><td bgcolor=beige>")
response.write (ReWrap(infoOut))
response.write ("</td></tr></table>")
end if
%>
</body>
</html>