Welcome to WebmasterWorld Guest from 54.221.49.52

Forum Moderators: open

Message Too Old, No Replies

Getting input field information with JavaScript

     

dreaming of nascar

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

10+ Year Member



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
www.something.com/whatever.htm?blah=blah&blah=blah

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

Thanks

D O N

rainborick

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

WebmasterWorld Senior Member 10+ Year Member



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!

DrDoc

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

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



www.something.com/page.html?blah=whatever

a = location.search.substring(1);

a is now "blah=whatever"...





...and that's 1000 :o

 

Featured Threads

Hot Threads This Week

Hot Threads This Month