• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form buttons multiple actions

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help!

I'll get right to the point. Is it possible to have a form submit button do more than one action? I want a form button that when clicked first will send the current window to the printer (which I know how to do) and then second will send data from a cookie file to a CGI script (which I also know how to do). The problem is making the button do both actions.

If you want to see the situation I'm using this for go to:
www.greenbayeasthighschool.com/store/commerce.cgi

when you get there, put an item in the shopping cart and go to the checkout. Put any data in the billing and shipping screen and click verify. In the next screen you'll see my print button at the bottom of the screen. This button prints the summary screen from further up on the page. The problem is, it doesn't empty the shopping cart items since it doesn't call the script that empties the cart and responds with an order confirmation screen. Is it possible to make the button do both actions?

Before anyone asks why I'm not using paypal or something like that to process the orders, it's because the people I'm building this for don't want to accept anything but checks or money orders yet.

Any help would be, of course greatly appreciated!
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Scott,

I haven't followed your link. If you want a submit button to do more than one thing you can put JavaScript in the button's onClick handler or the form's onSubmit handler. Bear in mind that it's generally considered bad practice to have actions with side-effects. As a user when I click a Print button, I expect something to print. I don't expect the thing I'm printing to disappear into the ether at the same time. What if, for example, my print fails, as is fairly common with a paper jam or something?

Anyway, it's up to you to decide what's appropriate.

Jules
 
Scott Christy
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's an excellent point. Probably the best solution is to make 2 separate buttons. One to print and then one to finish the processing of the order.

Besides, it would sure make the programming easier on my end.

Thanks for the advice.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic