Well, I'm on a Mac/Unix box so I can't test out a couple of possible
solutions I've found. Basically, microsoft has some ActiveX plugins
that are pretty easy to use to write to a file. Do a search for
javascript write file.
Another method is to create a Java Applet on your page that has
capabilities to write to your database - the javascript can then call
the java applet easily.
And finally - the solution I cooked up using on JavaScript is:
First - let's assume the path to the script is:
http://www.yoursite.com/cgi-bin/yourscript.pl
The script can take two arguements:
http://www.yoursite.com/cgi-bin/yourscript.pl?key=something&value=something
The page containing this script will actually be a page containing two
frames. (Now before you go and start screaming about the use of frames
- this method is fairly painless.)
One frame will be the frame displaying all of the checkboxes
(mainFrame) while the other will be a hidden frame that has absolutely
no bearing on the look/function/appearance of your page.
When a checkbox is clicked, it calls a JavaScript function - passing
it's name (which key it represents) and its value (on or off). The
JavaScript function then tells the hidden frame to go to the URL:
http://www.yoursite.com/cgi-bin/yourscript.pl?key=THEKEY&value=ON/OFF
Your script will then take these values and update the database accordingly.
Code is as follows:
Page containing the frames:
---------------------------------------
<html>
<head>
<title>Update Database</title>
</head>
<body>
<frameset cols="0,*" frameborder="NO" border="0" framespacing="0">
<frame src="http://www.yoursite.com/hiddenFrame.html" scrolling="NO" noresize>
<frame src="http://www.yoursite.com/theRealFrame" name="mainFrame">
</frameset>
</body>
</html>
---------------------------------------
The Hidden Frame Page:
---------------------------------------
<html>
<body>
</body>
</html>
---------------------------------------
The Real Page:
---------------------------------------
<html>
<head>
<title>Untitled Document</title>
<script language="JavaScript">
function UpdateDatabase(TheKey, TheStatus)
{
URL = 'http://www.yoursite.com/cgi-bin/yourscript.pl?key=' + TheKey +
'&value=' + TheStatus;
alert(URL);
parent.hiddenFrame.location.href = URL;
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input name="key1" type="checkbox" id="key1" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)">
</p>
<p>
<input name="key2" type="checkbox" id="key2" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)">
</p>
<p>
<input name="key3" type="checkbox" id="key3" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)">
</p>
<p>
<input name="key4" type="checkbox" id="key4" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)">
</p>
<p>
<input name="key5" type="checkbox" id="key5" value="checkbox"
onClick="UpdateDatabase(this.name, this.status)">
</p>
</form>
</body>
</html>
-----------------------------------------------------------------
That should get you started. I've already thought of a couple of other
issues - like maybe setting the status of each check box when the page
loads, but I don't know how much you need to know. Try creating this
page with a script and adding the "checked" keyword to the end of any
checkbox tagged that is checked. |