John,

I'm developing a framework here and everything went well `till I
started asking myself. Does it work if I have 2 forms present on one
page?
And all came tumbling down since, the submit event takes the second
set of options everytime i click the form submit button.

Shouldn't the first options be available to the form with the ID
"default_form" and the second options available to the second form
with the id "default_form2" ?


PS: The ajaxForm plugin is custom made:

jQuery.fn.ajaxForm = function(options) {

        options = jQuery.extend(options);

        if (typeof options.output == 'undefined') options.output =
'form_output';
        if (typeof options.success == 'undefined') options.success =
'form_success';
        if (typeof options.error == 'undefined') options.error =
'form_error';
        if (typeof options.submit_value == 'undefined') options.submit_value
= 'form_submit';
        if (typeof options.submit_text == 'undefined') options.submit_text =
'Submiting';


    return this.each(function() {
        jQuery("input:submit,input:image,button:submit", this)
    }).submit(function() {

        // build form array
        var form_array = [];
        jQuery("input,textarea,select,button", this).each(function() {

                if ((this.type == 'submit' || this.type == 'image' ||
this.type == 'text' || this.type == 'password' || this.type ==
'hidden' || this.type == 'textarea' || this.type == 'select-one') ||
                ((this.type == 'checkbox' || this.type == 'radio') &&
this.checked))
                {
                        form_array.push({name: this.name, value: this.value});
                }
                else if (this.type == 'select-multiple')
                {
                        var name = this.name;
                        jQuery('option:selected', this).each( function() {
                        form_array.push({name: name, value: this.value});
                });
                }
        });

        // validate form
        var url = this.action + (this.action.indexOf('?') >= 0 ? '&' :
'?') + 'ajax_submit=1';
        var form_id = this.id;

        // change submit value
        var old_submit_value =
jQuery('#'+options.submit_value).attr('value');
        jQuery('#'+options.submit_value).attr('value',
options.submit_text).attr('disabled', 'disabled');

        // post
        jQuery.post(url, form_array, function(json) {
                eval("var args = " + json);

             // output result
             if (args['errors'] == "")
             {
 
jQuery('#'+options.output).addClass(options.success).html(args['success']);

                if (args['hide_form'] == 1)
                {
                        jQuery('#'+form_id).hide();
                }
             }
             else
             {
                var errors = '';
                jQuery.each(args['errors'], function(i, n){
                        errors += n + "<br />";
                });

 
jQuery('#'+options.output).addClass(options.error).html(errors);
             }

             // reset the submit value
             jQuery('#'+options.submit_value).attr('value',
old_submit_value).removeAttr('disabled');
                });

        return false;
    });
};

On Jul 3, 3:59 pm, "John Farrar" <[EMAIL PROTECTED]> wrote:
> Carlin,
>
> It seems like a wrong approach to submit more than one form. By virtue a
> form is sort of a "domain" of information. If you have seperate forms they
> likely should be submitted seperately. There are ways to combine information
> so the form is split up into pages or even "tabs" for example of how to do
> it on one page. I am not saying that this is always possible (there are
> always client and boss issues) but it would be more ideal to approach it
> that way IMO.

Reply via email to