How to define an input id in javascript? - Stack Overflow

Hi i am not good in javascript. This is a part of code from my ajax search auto-suggest and i need to r

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
Add a ment  | 

2 Answers 2

Reset to default 3

This 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/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745665428a4639093.html

相关推荐

  • How to define an input id in javascript? - Stack Overflow

    Hi i am not good in javascript. This is a part of code from my ajax search auto-suggest and i need to r

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信