SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    scriptaculous autocompleter

    I posted this query in the javascript forum but someone suggested I might find more help here.
    I've built an autocomplete text field using scriptaculous/prototype and have added an afterUpdateElement option to it so that the form submits when a user selects an option from the autocomplete list. This worked fine until I added a standard submit button to the form as well. Now, the submit button works, but the afterUpdateElement doesn't.
    Any ideas?
    ps. if this is more a javascript problem then I apologise!

  2. #2
    SitePoint Enthusiast toytron's Avatar
    Join Date
    Nov 2006
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about:
    $(’myselect’).observe(’change’,function(){…});

  3. #3
    SitePoint Enthusiast TomK32's Avatar
    Join Date
    Mar 2008
    Location
    Berchtesgaden, Germany
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Some actual code might help but usually it's something with a missing "return" or "event.preventDefault()"
    just a geek trying to change the world
    I'm a ruby on rails developer in Vienna, Austria. My github.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's the javascript code:

    function buildAutocompleter()
    {
    new Ajax.Autocompleter(
    'ds',
    'autoCompleteMenu',
    '#', //this points to the php include that generates the list
    {
    minChars: 2,
    frequency: 0.5,
    afterUpdateElement: function() { document.destSearch.submit(); }
    }
    );
    }
    Event.observe(window, "load", buildAutocompleter);

    This is the html:

    <form action="" method="get" id="destSearch" name="destSearch" onsubmit="return checkForm(this);">
    <div id="searchbar">
    <div id="searchinput">

    <input type="text" name="ds" value="click and type destination" id="ds" align="middle" autocomplete="off" onfocus="clearMe(this)" onblur="returnMe(this)" />
    <div id="autoCompleteMenu" name="autoCompleteMenu" class="auto_complete"></div>


    </div><!-- end of searchinput -->
    <input type="submit" name="go" id="submit" value="search" />
    </div>
    </form>

    toytron, I'm not sure what you mean by your post. Could you explain it further for me?


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
  •