Reputation: 61
how i need fill out a input of my form with jquery.
I have my url: http://example.com/page.html?name=YourName=Mark
Upvotes: 0
Views: 3496
Reputation: 5487
You could use a function that returns the value of a querystring parameter and then set the form field accordingly:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null)
return "";
else
return results[1];
}
var sName = getParameterByName(name);
Then set the form field value using jquery:
$("#formFieldID").val(sName);
Upvotes: 2