Reputation: 1215
I have this line of code here. This is pretty much a textfield in HTML that gets the value typed in and stores it in the id called "inpKeyword."
<input type="text" name="keyword" value="Keyword" size="25" id="inpKeyword"/> <!-- enter search term -->
I need to have that value stored in a javascript var variable. Can someone please help me? I've been stuck on this problem for the past couple hours. Thanks in advanced!
Btw, this is all in a JSP page.
Upvotes: 0
Views: 87
Reputation: 11486
Alternatively, you could use jQuery:
var value = $('#inpKeyword').val();
Upvotes: 0
Reputation: 12847
Have you tried this?
var val = document.getElementById('inpKeyword').value;
Upvotes: 6