I have an HTML page with a form, containing only one field. The submit doesn't actually do a page refresh, but rather does local JavaScript processing.
This works great, but has one downside: you can't give someone a URL with the form presubmitted (e.g. http://example.com/myform?field=val
).
How can I tell jQuery that, on load, if the URL contains ?field=[val]
, to fill field
with val
and then do the submit JavaScript action?
(Bonus points if you can do this in reverse as well: when you submit, change the URL in the location bar from http://example.com/myform
to http://example.com/myform?field=[val]
, without doing a page refresh)