goodnabor
01-14-2007, 01:23 AM
I want to include a passed variable as an html hidden input variable. It is passed in the URL.
I know nothing about javascript.
I am given code by www.Aweber.com to pass the name and email address to the 'Thank You Page'.
That thank you page is actually a second form.
I want to have the second form populate the name and email address fields with the passed variables.
It would be nice to have the actual text display in the text box, so the user could change it if desired.
The code I was given only allows me to Print the variable.
I tried this code, but it didn't work.
<INPUT TYPE="hidden" name="fname" value='<script>printElement('custom fname')</script>'>
Here is the code that goes where I want to display the passed variable.
<script>printElement("custom fname")</script>
And here is the code in the head to make this work.
<script>printElement("email")</script>
And this is calling their Javascript;
<script language="JavaScript1.2">
<!--
// Trivial CGI variable display code Copyright 2004 AWeber Systems, Inc.
var query_string = (location.search) ? ((location.search.indexOf('#') != -1)
? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : ''; var elements = new Array;
// Load CGI variables into elements[] associative array
if(query_string) {
var pairs = query_string.split("&");
for(i in pairs) {
var tmp = pairs[i].split("=");
elements[unescape(tmp[0])] = unescape(tmp[1]);
}
}
// Print one element value indexed by key argument function printElement(key) {
if(elements[key]) {
document.write(elements[key]);
} else {
document.write("Undefined");
}
}
// -->
</script>
I hope I have included all the information you need.
I know nothing about javascript.
I am given code by www.Aweber.com to pass the name and email address to the 'Thank You Page'.
That thank you page is actually a second form.
I want to have the second form populate the name and email address fields with the passed variables.
It would be nice to have the actual text display in the text box, so the user could change it if desired.
The code I was given only allows me to Print the variable.
I tried this code, but it didn't work.
<INPUT TYPE="hidden" name="fname" value='<script>printElement('custom fname')</script>'>
Here is the code that goes where I want to display the passed variable.
<script>printElement("custom fname")</script>
And here is the code in the head to make this work.
<script>printElement("email")</script>
And this is calling their Javascript;
<script language="JavaScript1.2">
<!--
// Trivial CGI variable display code Copyright 2004 AWeber Systems, Inc.
var query_string = (location.search) ? ((location.search.indexOf('#') != -1)
? location.search.substring(1, location.search.indexOf('#')) : location.search.substring(1)) : ''; var elements = new Array;
// Load CGI variables into elements[] associative array
if(query_string) {
var pairs = query_string.split("&");
for(i in pairs) {
var tmp = pairs[i].split("=");
elements[unescape(tmp[0])] = unescape(tmp[1]);
}
}
// Print one element value indexed by key argument function printElement(key) {
if(elements[key]) {
document.write(elements[key]);
} else {
document.write("Undefined");
}
}
// -->
</script>
I hope I have included all the information you need.