RE: [WSG] two different submits in a form

2006-04-04 Thread Ted Drake
Hi All

This reminds me of something Jeremy Keith mentioned last year at the @media
conference.  When you find yourself trying too hard to make something do
what should be done by something else, stop, take a deep breath, and
evaluate what should really be used.

This rears it's ugly head when forcing a definition list into looking like a
table, using a table for layout, using css for behaviors, and using js for
server-side logic.

The answer was: don't use js. I just need to place two different names on
the submit buttons and let the form action handle the two different
behaviors depending on the name of the submit button. 

Thanks for the help. The almighty Hedger Wang (www.hedgerwow.com) gave me
some great advice on putting this together.

Ted


-Original Message-
From: listdad@webstandardsgroup.org [mailto:[EMAIL PROTECTED]
On Behalf Of Web Man Walking
Sent: Tuesday, April 04, 2006 2:35 PM
To: wsg@webstandardsgroup.org
Subject: RE: [WSG] two different submits in a form

Could you not just have 2 submit buttons and then on the target/action page,
check with one exists in the Request.Form collection (sorry ASP head) and
then do logic A or logic B?

-Original Message-
From: listdad@webstandardsgroup.org [mailto:[EMAIL PROTECTED]
On Behalf Of Marco van Hylckama Vlieg
Sent: 04 April 2006 22:18
To: wsg@webstandardsgroup.org
Subject: Re: [WSG] two different submits in a form

I'm thinking along the lines of:

Your form:

form id=yourform_id action=/some/path/default_action.php


script
function alternateSubmit()  {
   theForm = document.getElementById('yourform_id');
   theForm.setAttribute('action', '/some/path/somescript.php');
   theForm.submit();
   }
/script

The button for the alternate submit:

input type=button onclick=alternateSubmit(); /

I guess that should work.

Cheers,

Marco

On Apr 4, 2006, at 10:49 PM, Ted Drake wrote:

 Hi All
 I've got a question for the js people out there. I haven't found an  
 answer
 yet, but it should be fairly straightforward.
 We have a form that allows people to see their favorite products  
 and either
 select a few to compare them or send the group of products to a  
 friend.
 I'm using a form and the submit button is on the compare with the  
 action a
 php script that grabs the items checked and sends the user to the  
 comparison
 page.
 I need to make this other link do something similar. I was  
 wondering if I
 could use js to switch the action to the send the list action.

 I couldn't find anything on the web for doing this sorth of thing.  
 Does
 anyone have an example?

 thanks

 Ted Drake
 Front-end Engineer
 Yahoo! Tech


 **
 The discussion list for  http://webstandardsgroup.org/

  See http://webstandardsgroup.org/mail/guidelines.cfm
  for some hints on posting to the list  getting help
 **


**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**

**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**



Re: [WSG] two different submits in a form

2006-04-04 Thread Micky Mourelo
If, and only if, you really, really as in REALLY, have to do this on
the client side, use an event based script; no onclick, or onsubmit
(that is s 1997).

Remember to have the script on a separate file, not on the html
itself, and, sorry, AND, try to have the server side proccess the
compare option by default (making the compare a real submit button
and the other a javascript based) and, when it presents the
comparison, show them the send a friend option (in case they had
clicked send to a friend but the script failed/was not available/no
javascript enabled)

Or... I know some guys who could convince the person responsible for
not letting the server deal with form the way it should. A mere
hundred dollars would do.

Just so you know...
**
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list  getting help
**