I tried inserting a "return false;" into my jQuery below,
but it prevented the button from functioning as it needs.

Here's the jQuery:

                $(document).ready(function() {
                        $('#add-image').click(function() {
                                $('#image-next').clone(true).
                                attr('name', function() {
                                        return this.name.replace(/(.+)(\d+$)/, 
function(s, p1, p2) {
                                                return p1 + (parseInt(p2, 10) + 
1);
                                        })
                                })
                                .insertAfter('#image-div :last');
                        });
                });

And here's the button HTML:

<button id="add-image">Add New Image Field</button>

Got any ideas on how I could modify this?

I was using a link to add the file fields, but the link
was refreshing the page and taking me back to the top of the page.

Rick



> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Andy
> Matthews
> Sent: Monday, March 24, 2008 1:19 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Re: Using a button that doesn't submit?
> 
> 
> If you're already using jQuery just return false on the submit method for
> the form.
> 
> $('#myFormID').submit(function(){
>       // do stuff here
>       return false;
> });
> 
> -----Original Message-----
> From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Rick Faircloth
> Sent: Monday, March 24, 2008 12:15 PM
> To: jquery-en@googlegroups.com
> Subject: [jQuery] Using a button that doesn't submit?
> 
> 
> Hi, all...
> 
> I'm using some jQuery to add file fields to a page.
> 
> I'm using a button to trigger the jQuery.
> 
> <button>Add New Image Field</button>
> 
> In IE6 and IE7 the button just adds fields like I want, however, in FF2, the
> button submits the form.
> 
> How can I use the button with form submission?
> 
> I found plenty of info on Google about submitting a form without a button,
> nothing on using a button in a form with causing submission...
> 
> Rick
> 
> 


Reply via email to