Skip to content Skip to sidebar Skip to footer

Trying To Pass Url Parameters To Input Fields (not Form Fields)

I've used some time researching this, both here on SO and through Google. However I have not been able to find anything that helps me. Here is the scenario: I have a page (MP), wh

Solution 1:

This is possible even if your input fields are not part of a form element. Here is a working example to set the value of your affiliateID field.

functiongetQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = newRegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  elsereturnunescape(qs[1]);
}
var inp = document.getElementById("affiliateID");
inp.value = getQuerystring("affiliateID", "no ID given");

Update:

I misunderstood the question. This is not your website you're talking about, and you wanted to know if it was possible to change the form values using URL parameters. This is not possible. It is, however, common, that such a page is designed in a way that it accepts parameters via query string. You should ask the site's owner and ask him if you can pass the affiliate id somehow via URL.

Post a Comment for "Trying To Pass Url Parameters To Input Fields (not Form Fields)"