SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Prototype help..

    I have this piece of script, because i want to add the tags on enter.. and it works but only the first time.. is there any way to make it work after the first enter too ? :P

    Code:
        <script type="text/javascript">
        document.observe('dom:loaded' , function() {    
            Event.observe('search', 'keypress', function(event)
            { 
                function addTag(event) {
                    var tag = new Element('input' , { type: 'text', value: 'tag', rel: 'tag' });
                    $('form').insert(tag);
                    $('search').clear();
                    event.stop();
                }
                
                if(event.keyCode == Event.KEY_RETURN) {                
                    $('form' ).observe('submit' , addTag);
                }
            });
            new Ajax.Autocompleter("search","hint","server.php");
        });
        </script>
    Go visit my site :-D you know you want to ;-)
    www.mech7.net

  2. #2
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The strange thing is.. that the enters are being picked up, but somehow the submit is only not being checked anymore.. probably because of the even.stop() ? Is there any other way to prevent the form from begin submitted on one particular input field ?
    Go visit my site :-D you know you want to ;-)
    www.mech7.net


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
  •