I want to create a form like this:
- Type in your ID number into the form’s input and submit.
- The form’s action becomes something like
/account/{id}/.
I was told JavaScript was the only way to achieve this (see here), but how?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using jQuery it might look something like this:
This should change the action of the form any time the text in the input element changes. You could also use
.blur()instead of.change()to perform the action whenever focus leaves the input element, so it doesn’t keep changing all the time, etc. Then, when the form is submitted, it should submit to whatever was last placed in its action attribute.