A
allan_msdn
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 = this.q.split("&");
}
}
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
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 = this.q.split("&");
}
}
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