I’d like to be able to detect which form on a page was submitted, grab its ID and assign it to a variable. How can I do this?
Thank you!
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.
I assume you’re working with jQuery. You can easily do this:
Note that this variable will only be available within that JavaScript-code and only until the page is left/reloaded. If you want to save it permanently, you could e.g. post it to the server and then save it to the session / a database / a cookie / whatever.