Okay, I found a way to do what I want to do, but ran into something
else.  Using the jQuery Form plugin, I've managed to serialize the
form inputs and, via ajax, post the values to a page which returns a
JSON result:

$('[EMAIL PROTECTED]/run.png]').click (
        function ( e ) {
                var data = $('#filter').formSerialize();
                var report = this.id.replace ( /\w+-(\w+)/, '$1' );
                
                data += '&report=' + report;
                
                $.ajax ({
                        type: 'POST',
                        url: '/reports/' + report + '.php',
                        dataType: 'json',
                        data: data,
                        success: displayReport
                });                     
        }
);

The problem is that formSerialize() doesn't "properly" encode checkbox
values.  Given a set of checkbox options with the same name, normal
form encoding passes the values as a comma-delimited list.  The
serialized value just applies them separately to the query string so
that the only one that is read is the last one.

Instead of "&myselections=value1,value2, value3", I get
"&myselections=value1&myselections=value2&myselections=value3".

Has anyone else seen this?  Am I missing something?

Thanks.

On 4/27/07, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
I have a form on a page that doesn't have a submit button, per se.
Instead, there are a number of elements which, when clicked, should
submit the form to an action page that is specific to the element that
was clicked.  I see that I can ajax-ify a form, but I don't see how to
modify the action attribute at the time the form is submitted.

Currently, I have this working fine, but I need to implement a form
for user input while maintaining the dynamic action page and the ajax
nature.

$('[EMAIL PROTECTED]/run.png]').click (
        function ( e ) {
                var report = this.id.replace ( /\w+-(\w+)/, '$1' );

                $.getJSON  (
                        '/reports/' + report + '.php',
                        function ( result ) {
                                displayResult ( report, result );
                        }
                );

        }
);

Any help?

Thanks.

/rob

Reply via email to