RE: [OT - JS] onsubmit state

2005-05-11 Thread Dave Merrill
Typo in the PECULIAR ASIDE. It would normally be:
form.form_action[0].value

not:
form.form_action.value[0]

Doh!

Don't want to distract my own thread here, but what's still peculiar is that
form.form_action.value = whatever
(without the [0]) has the desired effect, even though there are multiple
form objects with that name. It still works without the hidden field. Still
odd, or I'm doing a brain blank again.

Dave Merrill

 Say you've got a form with multiple submit btns, each given the name
 form_action, but with different values. When the form is submitted, the
 clicked submit btn's value shows up as form.form_action, as expected.

 However, from within an onclick handler for any of those btns, or an
 onsubmit handler for the form, form.form_action.value is undefined. This
 means that validation or other code that needs to know which
 submit btn was
 clicked can't tell.

 What I've done in the past is to include a hidden form field
 whose value is
 what we pay attention to, and set its value in the onclick
 handler for each
 submit btn.

 Anyone have any other strategies?

 Dave Merrill


 PECULIAR ASIDE:
 Interestingly, to set the value of that hidden field, you use:
   form.form_action.value = whatever,
 even though there's a hidden field plus multiple submit btns, all with
 that name. Typically you'd need to access that hidden field as:
   form.form_action.value[0]
 but that generates an error. It's like the named submit btns
 don't exist
 on this level. Odd.



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206474
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: [OT - JS] onsubmit state

2005-05-11 Thread Ewok
Without knowing what exactly you're using it for, I'd say give the submit
buttons different names rather than values

-Original Message-
From: Dave Merrill [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 11, 2005 4:58 PM
To: CF-Talk
Subject: [OT - JS] onsubmit state

Say you've got a form with multiple submit btns, each given the name
form_action, but with different values. When the form is submitted, the
clicked submit btn's value shows up as form.form_action, as expected.

However, from within an onclick handler for any of those btns, or an
onsubmit handler for the form, form.form_action.value is undefined. This
means that validation or other code that needs to know which submit btn was
clicked can't tell.

What I've done in the past is to include a hidden form field whose value is
what we pay attention to, and set its value in the onclick handler for each
submit btn.

Anyone have any other strategies?

Dave Merrill


PECULIAR ASIDE:
Interestingly, to set the value of that hidden field, you use:
form.form_action.value = whatever,
.even though there's a hidden field plus multiple submit btns, all with
that name. Typically you'd need to access that hidden field as:
form.form_action.value[0]
.but that generates an error. It's like the named submit btns don't exist
on this level. Odd.





~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206475
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: [OT - JS] onsubmit state

2005-05-11 Thread Dave Merrill
The point is that regardless of what btn was clicked, its value hasn't
taken effect yet during onclick or onsubmit.

How does giving them different names help?

Dave Merrill


 Without knowing what exactly you're using it for, I'd say give the submit
 buttons different names rather than values

 -Original Message-
 From: Dave Merrill

 Say you've got a form with multiple submit btns, each given the name
 form_action, but with different values. When the form is submitted, the
 clicked submit btn's value shows up as form.form_action, as expected.

 However, from within an onclick handler for any of those btns, or an
 onsubmit handler for the form, form.form_action.value is undefined. This
 means that validation or other code that needs to know which
 submit btn was
 clicked can't tell.

 What I've done in the past is to include a hidden form field
 whose value is
 what we pay attention to, and set its value in the onclick
 handler for each
 submit btn.

 Anyone have any other strategies?

 Dave Merrill



~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206481
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: [OT - JS] onsubmit state

2005-05-11 Thread Ryan Sabir
In the onClick handler for the button, you can refer to the 'this'
object, or pass it to a function. 'this' will always refer to the
button that was clicked.

Can't do the same with onSubmit though. Maybe you could set a
javascript variable using the 'this' object on the onClick, and pick
up that variable to use in the onSubmit handler.

bye


Thursday, May 12, 2005, 6:58:24 AM, you wrote:

DM Say you've got a form with multiple submit btns, each given the name
DM form_action, but with different values. When the form is submitted, the
DM clicked submit btn's value shows up as form.form_action, as expected.

DM However, from within an onclick handler for any of those btns, or an
DM onsubmit handler for the form, form.form_action.value is undefined. This
DM means that validation or other code that needs to know which submit btn was
DM clicked can't tell.

DM What I've done in the past is to include a hidden form field whose value is
DM what we pay attention to, and set its value in the onclick handler for each
DM submit btn.

DM Anyone have any other strategies?

DM Dave Merrill


DM PECULIAR ASIDE:
DM Interestingly, to set the value of that hidden field, you use:
DM form.form_action.value = whatever,
DM even though there's a hidden field plus multiple submit btns, all with
DM that name. Typically you'd need to access that hidden field as:
DM form.form_action.value[0]
DM but that generates an error. It's like the named submit btns don't exist
DM on this level. Odd.



DM 

~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206491
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: [OT - JS] onsubmit state

2005-05-11 Thread Ewok
Ahh I misunderstood. I was thinking after it was submitted and in the form
scope of CF. (although it was very plain that it's not what you said...
don’t ask)

 write a function to use in the onclick of each button maybe?

script
function whatwasclicked(btn)
{
alert(btn);
//some if statements for different buttons here?
if (btn=='Button1')
{
//Do something for button1
}
else if (btn=='Button2')
{
//Do something for button2
}
}
/script

input type=button name=button1 value=Button1
onclick=whatwasclicked(this.value);

input type=button name=button1 value=Button2
onclick=whatwasclicked(this.value);

Again... don’t know what you're doing with it but that will put the VALUE of
the button in the var 'btn' inside the function to do whatever you want
with.


-Original Message-
From: Dave Merrill [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 11, 2005 5:32 PM
To: CF-Talk
Subject: RE: [OT - JS] onsubmit state

The point is that regardless of what btn was clicked, its value hasn't
taken effect yet during onclick or onsubmit.

How does giving them different names help?

Dave Merrill


 Without knowing what exactly you're using it for, I'd say give the submit
 buttons different names rather than values

 -Original Message-
 From: Dave Merrill

 Say you've got a form with multiple submit btns, each given the name
 form_action, but with different values. When the form is submitted, the
 clicked submit btn's value shows up as form.form_action, as expected.

 However, from within an onclick handler for any of those btns, or an
 onsubmit handler for the form, form.form_action.value is undefined. This
 means that validation or other code that needs to know which
 submit btn was
 clicked can't tell.

 What I've done in the past is to include a hidden form field
 whose value is
 what we pay attention to, and set its value in the onclick
 handler for each
 submit btn.

 Anyone have any other strategies?

 Dave Merrill





~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:206493
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54