Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Problems with action

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that the blank.do action is not being invoked?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
replace
<script type="JavaScript">
with
<script type="text/javascript">
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,I'm saying that the blank.do action is not being invoked.

Satou I replaced the tag but didn't work...
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try

onclick="cancel();return false;">

shot in the dark...

Eric
 
Giomar Guevara
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot Eric...

can you tell me what does the "return false" do??
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic