TJS wrote on 11 nov 2004 in comp.lang.javascript
:
trying to get 2 scripts to run when a button is clicked. The first
is a confirm which should only run the second script if true.
the problem is the second script doesn't run when "ok" is selected on
the confirm. What's wrong?
<INPUT TYPE="Image" src="../images/shop.gif" BORDER=0 TITLE="Continue
Shopping"
onclick="javascript: confirm('The selected items will be saved. \n
Do you
wish to proceed?');
location.href='./cart.asp?action=save';">
1 this is only one script !
2 leave the "javascript
:" out, superfluous.
3 leave the "./" out, superfluous.
4 try:
<script type="text/javascript">
tx = "The selected items will be saved.\nDo you wish to proceed?"
function conditionally(){
if(confirm(tx))
location.href='cart.asp?action=save';
}
</script>
<input
type="Image"
src="../images/shop.gif"
onclick="conditionally()"
style="cursor:pointer;">
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)