Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Query string parser redirects to new page

Reply
Thread Tools

Query string parser redirects to new page

 
 
allan_msdn@hotmail.com
Guest
Posts: n/a
 
      01-25-2006
Hi,

I'm working on a web-site for a company and part of the site has an
employee profile page. I need to pass different fields of information
for each employee to a e-mail a e-mail form. I have tried to pass the
information appended to a query screen. I have download a Javascript
query string parser to get the key/value pairs. I don't know
JavaScript well and avoid using it much, but I'm thinking someone who
knows it well could solve my problem.

I start at an employee profile page, hard code the link and append the
key/value pairs to the link which call a web-form page. I want to
populate the web-form page with data send from the employee profile
page. The web-form page contains the Javascript for parsing the query
string and also contains the html for the web-form. I would like to
populate certain fields in the web-form page for the visitor who uses
the webmail forms.I have two questions. First of, I don't know why the
Javascript code executes when I don't call any of its functions, but
most importantly why, any other code I include, like simple Alerts to
check values opens up on a third blank page. This is driving me crazy.

Here's the query parser:

function PageQuery(q) {
if(q.length > 1) this.q = q.substring(1, q.length);
else this.q = null;
this.keyValuePairs = new Array();
if(q) {
for(var i=0; i < this.q.split("&").length; i++) {
this.keyValuePairs[i] = this.q.split("&")[i];
}
}
this.getKeyValuePairs = function() { return this.keyValuePairs; }
this.getValue = function(s) {
for(var j=0; j < this.keyValuePairs.length; j++) {
if(this.keyValuePairs[j].split("=")[0] == s)
return this.keyValuePairs[j].split("=")[1];
}
return false;
}
this.getParameters = function() {
var a = new Array(this.getLength());
for(var j=0; j < this.keyValuePairs.length; j++) {
a[j] = this.keyValuePairs[j].split("=")[0];
}
return a;
}
this.getLength = function() { return this.keyValuePairs.length; }
}

function queryString(key){
var page = new PageQuery(window.location.search);
return unescape(page.getValue(key));
}

function displayItem(key){
if(queryString(key)=='false')
{
document.write("you didn't enter a ?name=value querystring item.");
}
else
{
document.write(queryString(key));
}


}

I'd really appreciate if someone could tell me why any other code I try
to execute runs on a third page. Ideally, I'd simply like to populate
the fields on each call to the webform like:

document.testform.datefield.value = dateString;

Thanks for any help,
Al

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert url with query string to url without query string nick Javascript 1 02-13-2011 11:20 PM
Prevent treeview control from reinitialising on master page for page redirects damiensawyer@yahoo.com.au ASP .Net 2 02-13-2006 09:58 PM
I am not hurting anyone ... am I ? (page redirects). craigkenisston@hotmail.com ASP .Net 1 02-02-2005 01:36 PM
page that redirects to another page every 45 seconds Mark Andrews ASP General 3 06-08-2004 08:01 PM
HttpModule for virtual page server side redirects and cookies Gery D. Dorazio ASP .Net 0 01-29-2004 02:03 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57