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 es from input. How can I do that?
<input type="text" id="selectedInput"/><ul id="list"></ul>
<script>
var keyword = "word"; (wrong code)
url: "=" + keyword + "&entity=musicTrack",
..
See /
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 es 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./search?term=" + keyword + "&entity=musicTrack",
..
See http://jsfiddle/coladeu/Qhj5N/3/
Share Improve this question edited Sep 23, 2012 at 18:54 Adi 5,1796 gold badges35 silver badges48 bronze badges asked Sep 23, 2012 at 18:50 BengauBengau 1755 silver badges14 bronze badges 2- When do you want it? When the page loads? Or when an event occurs? – I Hate Lazy Commented Sep 23, 2012 at 18:56
- i want it when event occurs. when i type characters, to start show me the suggestions. i dont think is that hard but i am not good in js. – Bengau Commented Sep 23, 2012 at 20:11
2 Answers
Reset to default 3This will obtain the value in your textbox.
var keyword = document.getElementById('selectedInput').value;
Edit:
Just as an FYI, the same thing can be acplished using jQuery:
$('#selectedInput').val();
You can use $('#selectedInput').val()
here is an example
http://jsfiddle/Qhj5N/4/