Hi all,
I'm having trouble processing forms:
The website should work as follows:
1/ Web page form presents simple <input id="search"> box which returns
rows from a DB.
2/ The returned rows are entered into only one div <div id="results">
in the manner of a HTML table/form.
3/ The user can modify items on the form and then submit the form
again for processing and the outcome updates the DIV.

I've tried two approaches without success:
A/ I can't place the "modify" form inside the first search form - In
firebug, the "modify" FORM tags just don't appear.
B/ I can't reuse the first search form using different values. E.G:
        if id="search" do search_db();
        if id="update" do update_db();
   as I keep getting element is null errors, despite trying to check
for null - I'm new to Javascript.
My code is as follows:

window.onload = function ()
        {
        $('search_form').onsubmit = function ()
                {
                        if(!$F('search')) { $search_db(); return
false;   }
                        if(!$F('update')) { $update_db(); return
false;   }
                }
        }
        function search_db()
                {
                new Ajax.Updater ('results', 'http://website.com/search_form',
{method:'post',postBody:'search='+$F('search')});
                }
        function update_db()
                {
                new Ajax.Updater ('results', 'http://website.com/search_form',
{method:'post',postBody:'update='+$F('update')});
                }

Questions: 1 /Is the a better way to do this?
                 2/ How do I choose either of the above functions
without getting caught on 'element is null' errors on the other
element?
Thanks
Dave

-- 
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 prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to