POST and HTML Forms
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

POST and HTML Forms

From: accyboy1981 <accyboy1981@gmail.com>
Date: Wed Nov 02 2005 - 18:17:30 CET

Hi,

I am currently designing an HTML page with a form with a post method.
The page is calling itself so with the details that are passed will
vary how the page will look i.e. number of results from the sql query
that is being run. I'm trying to catch these using a javascript
function which is:

var qsParm = new Array();
function qs() {
var query = window.location.search.substring(1);
document.writeln(query);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
   var pos = parms[i].indexOf('=');
   if (pos > 0) {
      var key = parms[i].substring(0,pos);
      var val = parms[i].substring(pos+1);
      qsParm[key] = val;
      }
   }
}

and then just calling the array to get the value, in this case
qsParm['num_res']. The above function doesnt work for post but does for
get. I'm fairly new to javascript and am assuming this line is at
fault:
var query = window.location.search.substring(1);
but I'm not sure what it should be.

Any help will be much appreciated.

Thanks

Simon
Received on Mon Nov 21 03:16:35 2005