How to define an input id in javascript? Help

Discussion in 'JavaScript' started by coladeu, Sep 23, 2012.

  1. #1
    Hi i am not to good in javascript. This is a part of code from my ajax search auto-suggest and i need to replace "the word" with the input id somehow and i dont know how to do it. need some help please.
    here is a link to the entire code demo. http://jsfiddle.net/coladeu/Qhj5N/
    <input type="text" id="[B]selectedInput[/B]"/><ul id="list"></ul>    
    <script>    
    [B]var keyword = "the word[/B][B]"; [/B] (wrong code)      
    url: "http://itunes.apple.com/search?term="[B] + keyword +[/B] "&entity=musicTrack",
    ..
    Code (markup):

     
    coladeu, Sep 23, 2012 IP
  2. php_developer

    php_developer Peon

    Messages:
    63
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    look there is a text box with id="selectedInput" now what u have to do is make a variable like this in java script and stored that id which is in text box.
    var x=document.getElementbyId("selectedInput").value;
    using this variable you can store the text box value in var x and then u can use it where u need this variable.
     
    php_developer, Sep 23, 2012 IP