Hi Karl,
Thanks for your help.
Yes I am using firebug but I'm generally new to JS and Prototype.

I've adopted the approach you suggested but I can't seem to determine
which button is being pressed.

Search form:
<form method="post" action="null"  id="search_form" value="search-
submit">
..
<input id="search" type="submit" value="search" name="search" />

When the results from the DB are displayed, a new button is displayed
under the form:
<input id="search" type="submit" value="update-submit" />

And the old (search) submit button is hidden so that only the 'update'
button is now visible:
$('search-submit').style.display = 'none';

When the new 'update' button is clicked, I should be able to detect
this and process the post variables but I keep seeing the first
'search' button being pressed even when I press the 'update' button.

QUESTIONS: 1/ How do I determine which button is pressed.
           2/ In the update context, when multiple post values submitted: How
do I process them without getting element is undefined problems?
Thanks Dave
-----------------------------------------------------------------------------------------------------------------------------------------------

JS code:
document.observe('dom:loaded', function()  {
                        var form = $('search_form');
                        Event.observe(form, 'submit', 
process.bindAsEventListener());
       });

        function process(e){
                e.stop();
                var elm = e.element();
                var v = elm.readAttribute('value');
                var i = elm.readAttribute('id');
                var n = elm.readAttribute('name');
                alert('Value='+v+'');
                alert('ID='+i+'');
                alert('Name='+n+'');
                if(elm.readAttribute('value') == 'search-submit') { search(); }
                if(elm.readAttribute('value') == 'update-submit') { update(); }

        }
        function search()
                {
                alert('Search context');
                new Ajax.Updater ('results', 'http://website/search_form',
{method:'post', postBody:'search='+$F('search')});
                $('search-submit').style.display = 'none';
                }
        function update()
                {
                ...
                }

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to