I’m looking for how to get input from a webpage into a JavaScript variable?
[EDIT]
Sorry I wasn’t clear. I needed to get a user to input some text that I could capture into a variable. I then need to split this variable up, do a search, like Google on each element, then display the results on the screen.
As I understand it I can use jQuery’s get method to look up the information, then get each response out and put it on the screen. Thanks for the pointers to jQuery I can now proceed further
There are several ways. One would be to have an input field of type text, then attach an event listener to the input field which responds to the enter key?
then in js
Or if you want to interrupt flow until you get a response, you could use
prompteg.As pointed out my code above requires jQuery – this is a library which makes using javascript much easier when coding for multiple browsers. It’s worth taking a look at it at http://jquery.com it’s very easy to make use of by simply adding in a script tag pointing at the jQuery library eg.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" />