Forum Moderators: open

Message Too Old, No Replies

Two Submit buttons ASP

         

andrewsmd

6:29 pm on May 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Everytime I try to put two submit buttons on any page, the latter of the two will never work. If I place one or the other they both work individually, but never if they are both on the page at the same time. There has to be a way around this. Does anyone know what it is?

LifeinAsia

6:44 pm on May 29, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Did you try giving them different names? e.g.,:
<input type="submit" name="Submit1">
<input type="submit" name="Submit2">

andrewsmd

6:50 pm on May 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes I did I appreciate the help but I'm not that bad of a programmer.

LifeinAsia

7:15 pm on May 29, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Don't know what to tell you- I do it all the time. (It even works for me without giving them different names.)

Are you doing any type of JavaScript event when the form is submitted?

Maybe you should include some of the code here.

Ocean10000

8:04 pm on May 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Question are you binding the buttons to two different Event Handlers or the same one? If you bind it to the same one, you will have to do a bit of extra work to determine which button fired the event.

marcel

5:19 am on May 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you actually using input type="submit" or asp:Button?

If it's the former, it will be difficult to get working as they are both within a single form.

andrewsmd

3:59 pm on May 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am using the latter. Here's the weird thing. I left Thursday with them not working. I always restart my computer when I leave work. I came in Friday to the exact same code and they worked fine. How crazy is that! A correlating question though. How do I get the enter button to submit each form separately. I.e. if they are entering stuff in the textbox that goes with button one, when they hit enter it submits button one. However, if they are enter text in the textbox that goes with button two and hit enter, it still submits button one. How do I overcome that? Thanks,

mattglet

8:38 pm on Jun 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assign OnClick events to each button, and have that handler perform whatever task you're looking to do.