I'm wanting to get the current page URL on submit from my form and populate the "value" attribute on an input type hidden with the URL on submission.
Currently I'm statically adding in a URL (http://www.google.com) to see if I'm populating the value attribute the right way but using .val() on the selector however, this doesn't seem to populate the attribute?
See my submit function below - I have added a class to the input called referrer-page.
HTML
<input type="hidden" class="referrer-page" name="00N20000002A4au" type="text" value="URL HERE!" />
jQuery
setupOnSubmit = function () {
var submitButton = $j('.submit_form'),
emailIcon = $j('.email-icon'),
referrerPage = $j('.referrer-page');
emailIcon.on('click', function(){
$j(this).submit();
referrerPage.val("http://www.google.com");
});
//Pass URL on submit
submitButton.on('click', function(){
referrerPage.val("http://www.google.com");
});
};