0

how i need fill out a input of my form with jquery.

I have my url: http://example.com/page.html?name=YourName=Mark

1
  • If English is not your native language, try using translate.google.com to help turn this into a valid question. Commented Jan 28, 2010 at 18:14

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

1 Comment

your querystring would look something like this example.com/page.html?name=Mark

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.