I want to do THIS with input TAG

Discussion in 'JavaScript' started by xantoniox, Sep 26, 2009.

  1. #1
    Hi everyone :D
    If you go HERE

    you will see a simple autosuggest.

    If you type G in input field, then appears:

    Gina Lollobrigida

    Gilda Montesano


    I want that clicking on it, the text ( Gina Lollobrigida o Gilda Montesano ) appear in input field ( Now appear CIAO ).

    And then I want that if the user type a different value from Gina Lollobrigida o Gilda Montesano, then this is delete automatically in input field.


    Help :)
     
    xantoniox, Sep 26, 2009 IP
  2. Jj delc

    Jj delc Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try using Jquery, you'll find lots of autocomplete plugins that will allow you to do that.
     
    Jj delc, Sep 27, 2009 IP
  3. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    The issue is with the PHP response, not the javascript. The response for typing in 'g' is here:
    http://idiotclip.com/film/lib/search.php?q=g

    This is what it looks like:
    
    <ul>		<li><a href="#" onclick="document.getElementById('search-q').[COLOR="Red"]value='CIAO'"; [/COLOR]>Gina <small>Lollobrigida</small></a></li>
    			<li><a href="#" onclick="document.getElementById('search-q').[COLOR="red"]value='CIAO'[/COLOR]"; >Gilda <small>Montesano</small></a></li>
    	</ul>
    
    Code (markup):
    You need to change the php script to make the highlighted parts the same as the returned name. Should be done very easily.
     
    camjohnson95, Sep 28, 2009 IP
  4. xantoniox

    xantoniox Active Member

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4

    Thank you very very much !! Now work well :)
     
    xantoniox, Sep 28, 2009 IP