Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Getting input field information with JavaScript

12:59 am on Apr 18, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 6, 2003
votes: 0

I was wondering how you get JS to get the input field information (I am not sure if I am calling that correctly). What I mean is that you have an address like www.something.com and when you submit a form, you go to

What I want to know is how do you read the blah=blah&blah=blah into JS. I hope that this makes sense.



3:29 am on Apr 18, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
votes: 34

The information you're after is generally called the Query String. The query string can be accessed via the "location.search" property in JavaScript. Apparently all of the people who have been enhancing JavaScript over the last few years are also Perl programmers, because there are several functions/techniques that are commonly used in Perl for manipulating this information in form-handling cgi scripts that are also available in JavaScript. For example, the "split" function makes it simple to parse the parameters in the query string and subsequently the name/value pairs. Good luck!
3:32 am on Apr 18, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
votes: 0


a = location.search.substring(1);

a is now "blah=whatever"...

...and that's 1000 :o