0

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), where I send people on to an affiliate (AP) of mine. It's very important that they fill out the fields on the AP correctly, else I will not get credited. Therefore I would like my affiliate link (AL) to include parameters to pass on to the form on the AP. The problem, however, is that the "form" on the AP is not actually a form, but a combination of input fields. Here is a snippet from the AP (remember I can not edit this code):

<tbody class="original">
<tr><td colspan="3"><p><strong>* required</strong></p></td></tr>
<tr>
<th width="180"><label for="affiliateID">Affiliate ID</label></th>
<td width="250"><div class="text"><input id="affiliateID" name="affID" class="text"></div></td>
</tr>
<tr>
<th width="180"><label for="txtEmail">Your e-mail address</label></th>
<td width="250"><div class="text"><input id="txtEmail" name="email" class="text"></div></td>
</tr>
<tr>
<td colspan="3">
<input id="submitInfo" class="submit" type="submit" value="Sign-up">
</td>
</tr>
</tbody>

My question is, will I be able to address and "pre-fill" the fields #affiliateID and #txtEmail by passing the values in my url from MP? I've tried to use: http://www.APURL.com?affiliateID=AF54728 and other stuff as well, but I am simply not able to get it to "prefill". Is this only possible to do if the AP is using a traditional HTML form or will I somehow be able to include it in the linking URL, so the AP recognizes that I want to pass a value to a certain field on his page? I was thinking there might be a way to address the ID of the input in the URL.

Hope someone can help me out here.

Thanks in advance.

1
  • Using form or not, you will still need to set the value to the Input using JavaScript... What is your http server? Commented Apr 8, 2014 at 8:00

1 Answer 1

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.

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_;
  else
    return unescape(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.

Sign up to request clarification or add additional context in comments.

3 Comments

But this is not possible - as mentioned in my post, I do not have access to the affiliate page code, therefore I can not use any scripts to do it. The question is regarding the possibility to pass the desired input through an URL. This is the sole option I have.
@NikolajLandrock Okay, I didn't get that. Then the answer is no. It is not possible, using URL parameters, to force form fields to have certain values. This would be a huge security risk. It is, however, common, that such a page is designed in a way that it accepts parameters via query string.
Thanks for the answer. This was exactly the sort of answer I was looking for. :) I will have to reach out to the affiliate and ask him to add the possibility. In regards to the security risk, I don't think it's that huge, when you are passing non-sensitive information. If it was password, bank account information etc. then I guess you are absolutely right! Thanks again for the straight answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.