I have a javascript snippet:
<script language="JavaScript" type="text/javascript" src="/partner/display.php?token=id"></script>
It's from the affiliate program we use, iDevaffiliate.
When included in the html of a page, it reads a value (the affiliate id) to the page, so the visitor can see it.
I need to get this same value inserted into to a hidden form field such as:
<input type="hidden" name="affid" id="affid"" value="value goes here">
This will allow us to submit the affiliate id in the form as a hidden value.
Any suggestion on how to include the value outputed by the javascript snippet as a value into the hidden form field?
The script itself doesn't work as a value in the form, atleast when I tried it in different ways. Thanks for any help.
Here is example page with js in the page, and a sample form. The value -100 should be created and visible when viewing the page (from the js): http://www.lifeleap.org/100-1-3-19.html
After Help and More Research, This Is What I Have So Far:
Script prints value here: <div id="affjs"><script language="JavaScript" type="text/javascript" src="/partner/display.php?token=id"></script></div>
<script type="text/javascript">
$('#testform').submit(function () {
var outputValue=document.getElementById("affjs").innerHTML;
document.getElementById("aff").value=outputValue;
});
</script>
<form method="post" action="/scripttest3.php" id="testform">
<input type="hidden" name="aff" id="aff" value="">
<button type="submit" value="Submit">Submit</button>
</form>
It's not finished, but I think I'm on the right track. Maybe onsubmit script needs to be included inside form? Thanks for any suggestions.