R
Ryan Goodman
I have searched high and low on the web and have been hacking at it for
quite a few hours and figured I would turn to the experts.
Functionally, I want to consume a parameter from a URL and place it
inside of a new A HREF. In my example the parameter is "partnerid"
http://ryangoodman.net?partnerid=xyz
Does someone have anything in their code toolbox to do this? I have
this code which I found on the web that takes "partnerid" and places it
in a form, which fills in half of the functionality. The other half, is
using the same parameter and putting it at the end of an A HREF. I
appreciate any help.
-----------Code-------------
<script language="JavaScript">
<!-- Begin
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1,
document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs.split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End -->
</script>
<form name="myForm" action="submit.cgi" >
Passed Variable 'Name': <input type="text" name="edtName">
</form>
<script language="JavaScript">
<!-- Begin
pvName = unescape(params["partnerid"]);
document.myForm.edtName.value = pvName;
// End -->
</script>
-----------Code-------------
quite a few hours and figured I would turn to the experts.
Functionally, I want to consume a parameter from a URL and place it
inside of a new A HREF. In my example the parameter is "partnerid"
http://ryangoodman.net?partnerid=xyz
Does someone have anything in their code toolbox to do this? I have
this code which I found on the web that takes "partnerid" and places it
in a form, which fills in half of the functionality. The other half, is
using the same parameter and putting it at the end of an A HREF. I
appreciate any help.
-----------Code-------------
<script language="JavaScript">
<!-- Begin
function getParams() {
var idx = document.URL.indexOf('?');
var params = new Array();
if (idx != -1) {
var pairs = document.URL.substring(idx+1,
document.URL.length).split('&');
for (var i=0; i<pairs.length; i++) {
nameVal = pairs.split('=');
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
params = getParams();
// End -->
</script>
<form name="myForm" action="submit.cgi" >
Passed Variable 'Name': <input type="text" name="edtName">
</form>
<script language="JavaScript">
<!-- Begin
pvName = unescape(params["partnerid"]);
document.myForm.edtName.value = pvName;
// End -->
</script>
-----------Code-------------