[thelist] JavaScript - closing parent window + big tip

Steve Cook sck at biljettpoolen.se
Wed Dec 20 06:36:11 CST 2000

Cheers both Jeff and Peter.

It's working now (I really must buy a JavaScript book!).

<tip type="Interface idea">

You can build form elements that update themselves! This is useful for an
Intranet application for instance where download times are usually an order
of magnitude better than on the Internet (your mileage may vary!).

The idea is to build a javascript that responds to an event on a form
element (it can be onClick, onChange or whatever is most appropriate for
that element) by submitting the value to your database. Here's an example:

The link;
<input type="checkbox" name="cheMail2Answer" align="middle" value="1"
onClick="leapTo(this.value, this.name)">

Runs this function

function leapTo (strValue, QueryElement) {
	// Watch out for the VBScript buried in here to dig out some of the
required variables
	var new_url="update.asp?element=" + QueryElement + "&pageNum=<%=
scriptNum %>&value=" + strValue + <%= "'&" &
Request.ServerVariables("QUERY_STRING") & "&from="  &
Server.UrlEncode(Request.ServerVariables("PATH_INFO")) & "'" %>;


This code opens an asp with a query string built up of the information
needed to submit to the database and then return to the original page. In
this case, the value and name of the form element plus the original
QUERY_STRING and PATH_INFO values for the page.

Update.asp then performs the necessary database updates and returns a
location header that returns the page to its original location, but updated
to reflect the form changes that have been made.

In this way, one can build a web application that responds to form changes
in much the same way that a normal Windows based application does, which can
both speed up use of the application and make the application easier to
learn for your non-web fanatic colleagues.


<phew> That was a long one!


   WapWarp - http://wapwarp.com
 Wap-Dev - http://www.wap-dev.net
 Cookstour - http://cookstour.org

More information about the thelist mailing list