Reputation: 175
Hi i am not good in javascript. This is a part of code from my ajax search auto-suggest and i need to replace "word" text with the text that comes from input. How can I do that?
<input type="text" id="selectedInput"/><ul id="list"></ul>
<script>
var keyword = "word"; (wrong code)
url: "http://itunes.apple.com/search?term=" + keyword + "&entity=musicTrack",
..
See http://jsfiddle.net/coladeu/Qhj5N/3/
Upvotes: 2
Views: 6038
Reputation: 13682
This will obtain the value in your textbox.
var keyword = document.getElementById('selectedInput').value;
Edit:
Just as an FYI, the same thing can be accomplished using jQuery:
$('#selectedInput').val();
Upvotes: 3