| Author |
Problems with action
|
Giomar Guevara
Ranch Hand
Joined: Oct 18, 2006
Posts: 51
|
|
Hi, I have 2 buttons, one to save a page and one to cancel it. When I hit the cancel button it should perform the "cancel" action but instead it does the action related to the save button This is my code: <input type="image" src="../images/button_save.gif" alt="save" title="Save taxonomy" accesskey="S"/> <input type="image" src="../images/button_cancel.gif" alt="cancel" title="Cancel New Taxonomy" accesskey="C" oncclick="cancel()"> <script language="JavaScript"> function cancel() { document.forms[0].action="/nserverManager/sam/blank.do"; document.forms[0].submit(); } </script> Any ideas? PD on purpose I wrote wrong the onclick method so I could post this message thanks [ October 25, 2006: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
|
Are you saying that the blank.do action is not being invoked?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14669
|
|
replace <script type="JavaScript"> with <script type="text/javascript">
|
[My Blog]
All roads lead to JavaRanch
|
 |
Giomar Guevara
Ranch Hand
Joined: Oct 18, 2006
Posts: 51
|
|
yes,I'm saying that the blank.do action is not being invoked. Satou I replaced the tag but didn't work...
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
try onclick="cancel();return false;"> shot in the dark... Eric
|
 |
Giomar Guevara
Ranch Hand
Joined: Oct 18, 2006
Posts: 51
|
|
thanks a lot Eric... can you tell me what does the "return false" do??
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
I think there is a race condition there and your function lost. The image is submitting before your code is run. So I had you cancel the image submit so your code would do the submission. You probably could change it to be: onclick="return cancel();"> AND function cancel() { document.forms[0].action="/nserverManager/sam/blank.do"; return true; } and it probably will work. Eric
|
 |
 |
|
|
subject: Problems with action
|
|
|