I want users to enter something in an text field, press OK and then run a function on the value of that text.
I have been looking at jQuery docs, I found keyup which gets the value instantly (not what I want) and the only things I can find about doing stuff with submitted form data involve POSTing the results to a php file or something.
I am keen to learn so if you could post links to resources where I could find out more along with your answer I would be most grateful. Thanks.
You don’t need a
<form>for this (if you’re not sending any data anywhere), just a set of<input>elements will do, for example:And jQuery like this:
You can test it out here, all we’re doing is attaching a handler to the button via
.click()and getting the value from the textbox via.val()…and then using that however you want, in this case passing it as a parameter to the function.