Results 1 to 5 of 5

Thread: Dropdown list

  1. #1
    Join Date
    Sep 2008
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Dropdown list

    Hi there this is my first post, i'm new to javascript so please be patient.
    Sorry for my english as i'm portuguese but i will try my best.

    I've done a dropdown list with CSS, AJAX and PHP. The idea is that when the user types in something a list appears underneath the control so can help to fill in, a sort of when you type on the search of google you get a list of the words and number of results. Everything works fine but i want to use the arrow keys to navigate in the box and not only the mouse.

    The problem is that the focus is on the control and not on this floating div, so i cannot figure out how to move the focus to this div and navigate with arrow(up and down) keys.
    I don't know even if this is the right approach to build something like this, but i thought it was good.

    Here is my code
    HTML Code:
    <input type="text" name="txtCountry" id="Country"  onblur="validate('Country', this.value, event);" onkeyup="fill('Country', this.value, this);"/>
    on key up the calls javascript and executes
    Code:
    document.write('<div id="pulldown" style="visibility:hidden; width:'+ size +'px" ></div>');
    
    function fill(what, str, targ){
    	var url = "scripts/signup/signup.php";
    	fillwhat = what;
    	action = 'fill';
    	target = targ;
    	url += "?id=" + what + "&action="+ action + "&str=" + str;
    	xmlHttpOpen(url);
    	
    }
    goes to PHP and retrieves the following response for example
    HTML Code:
    <ul><li id="AD" onmouseover="fillCountry(this.innerHTML, this.id);" onblur="hidepulldown();" onclick="hidepulldown();">Andorra</li>
    <li id="AE" onmouseover="fillCountry(this.innerHTML, this.id);" onblur="hidepulldown();" onclick="hidepulldown();">United Arab Emirates</li>
    <li id="AF" onmouseover="fillCountry(this.innerHTML, this.id);" onblur="hidepulldown();" onclick="hidepulldown();">Afghanistan</li>
    <li id="AG" onmouseover="fillCountry(this.innerHTML, this.id);" onblur="hidepulldown();" onclick="hidepulldown();">Antigua And Barbuda</li>
    <li id="AI" onmouseover="fillCountry(this.innerHTML, this.id);" onblur="hidepulldown();" onclick="hidepulldown();">Anguilla</li>
    </ul>
    when i go with mouse over each item it fills the text box with the value, what i would like is to do the same with the arrow keys.

    I've seen this effect here when you fill the field hometown http://www.wayn.com/waynsplash.html?wci=login i think its done with css.

    Or any idea how to do this?


    Thanks
    Last edited by tuga; 09-04-2008 at 04:05 PM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't see anything under Hometown, do you mean just a simple:
    HTML Code:
    <select>
    <option>Hi</option>
    <option>Hi</option>
    <option>Hi</option>
    <option>Hi</option>
    </select>
    Jeremy | jfein.net

  3. #3
    Join Date
    Sep 2008
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    You don't see anything because they use AJAX, create a div, position with css and put the information there, if you type at least 3 letters something comes up.

    I found that the behaviors are done with key events so i will try, if i can do it i will put the code here.

    Maybe this is a nice script for someone with better knowledge than me do it.
    Last edited by tuga; 09-05-2008 at 11:36 AM.

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    In mburts framework:
    http://mikeburt.net/framework/
    It looks like he has a function like that, see if you can contact him and get it to work.
    Jeremy | jfein.net

  5. #5
    Join Date
    Sep 2008
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanks nile i actually found a solution here for everyone who is interested http://www.brandspankingnew.net/arch...uggest_v2.html

    I'm not using since i've already written the code

    Thanks
    http://actualwebdesign.com
    http://express-transfers.com
    Last edited by tuga; 09-21-2008 at 09:17 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •