Passing a Querystring on to another web page


When I click a radio button in a certain web page (rather than a text link), I send the user on to another page.

Further requirements gathering in this project mandates that I pass a querystring on to that page.

The querystring is already captured and parsed in the host page and assigned to javascript variables and assigned to form fields.

For reasons of consistancy in Look and Feel, I use a radio button with a label as a link to another page if the user’s needs requires them to go there.

If they do go there, I need to send along that same querystring.

Here is my button click action javascript:

<input type="radio" name="_fid_30"
onClick="window.location='webpage.html'" />

At the end of that ‘webpage.html’, I wish to append the querystring that already is captured in the host page’s URI.

Here is the javascript wherein I’ve captured the querystring:

<script language="javascript">
function getQuerystring(key, default_)
  if (default_==null) default_="";
  key = key.replace(/[\\[]/,"\\\\\\[").replace(/[\\]]/,"\\\\\\]");
  var regex = new RegExp("[\\\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
    return qs[1];
var koID_val = getQuerystring('koID');
var UID_val = getQuerystring('UID');
var GivenName_val = getQuerystring('GivenName');
var MiddleInitial_val = getQuerystring('MiddleInitial');
var SurName_val = getQuerystring('SurName');
var Title_val = getQuerystring('Title');
var Email_val = getQuerystring('Email');
var QS_val = "?koID="+koID_val+"&UID="+UID_val+"&GivenName="+GivenName_val+"&MiddleInitial="+MiddleInitial_val+"&SurName="+SurName_val+"&Title="+Title_val+"&Email="+Email_val

With my last variable, “QS_val”, I’m attempting to capture within that variable the querystring only.

I’ve attempted to append this value at the end of ‘webpage.html’, but when I click the radio button, I arrive at the page, but there is no querystring.

I appreciate any help with passing the querystring on to the next web page when the radio button is clicked.


When I pull the desired destination URI into a function and call that function upon clicking the radio button, the desired results are achieved.

This is what I had before:

<input type="radio" name="_fid_30"
onClick="window.location='webpage.html'" />

(What’s missing in the code above is the attempt to ‘append’ the querystring to the end of this URI - - it wasn’t pretty)

And this is what I changed the above code to:

<input type="radio" name="_fid_30"
onClick="gotowebpage();" />
function gotowebpage(){
window.location ="webpage.html"+"?koID="+koID_val+"&UID="+UID_val+"&GivenName="+GivenName_val+"&MiddleInitial="+MiddleInitial_val+"&SurName="+SurName_val+"&Title="+Title_val+"&Email="+Email_val;

I find this solution far less clunky than what I was ‘attempting’ to do. In the event of a page change, placing the JavaScript function just below the event that calls it will make maintenance easier.