[thelist] Javascript & forms

.jeff jeff at members.evolt.org
Fri Feb 22 01:24:00 CST 2002


ryan,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Ryan Owen
>
> I am having some trouble moving my variables from the
> form to another page.  Here's a little example of what
> I am doing:
>
> On form.html page:
> //<form action="nextpage.html" method="get" name"form1">
> //<input type="text" name="name">
>
> On nextpage.html:
> //<script language="javascript">
> //var name = document.form1.name.value;
> //document.write(name);
> //</script>
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

since you're using the "get" method, the name/value pairs will be in the
url, meaning there's a mechanism to get at them.  some time ago i got tired
of creating a query string parsing routine whenever i wanted to retrieve
name/value pairs from the url, so i wrote a very basic one i could include
whenever i needed this functionality.

you can find an example, and downloadable source code here:

http://members.evolt.org/jeff/code/js_url_variables/

using your example above, the value of the "name" element can be accessed by
using url.name or url['name'].

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/




More information about the thelist mailing list