...

View Full Version : What is wrong with this?



michshelly
01-30-2006, 06:19 AM
Hi once again,

What is wrong with this code, please? I have tried every possible combination. Half of it is right. The part that is wrong is when you click on cancel, and the next box comes up saying "That's great". It's supposed to pop up saying "oh, that's a shame".

What I am not sure of is the calling function. Your input and advise would be really appreciated.
Thanks
Michelle

<html>
<head>
<title> Would you like some coffee?</title>

<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

function coffee () {

window.confirm("Would you like a cuppa?");

if (answer="true")
window.alert("That's great");


else {
(answer="false")
window.alert("Oh, that's a shame");

}
}

//STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</script>

</head>
<body>

<p> Invitation </p>

<script type="text/javascript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

coffee("window.confirm");

// STOP HIDING FROM INCOMPATIBLE BROWSERS-->
</script>
</body>
</html>

glenngv
01-30-2006, 06:37 AM
function coffee () {
var answer = window.confirm("Would you like a cuppa?");
if (answer) { //OK
window.alert("That's great");
}
else { //Cancel
window.alert("Oh, that's a shame");
}
}
...
coffee();

michshelly
01-30-2006, 12:31 PM
Hi glenngv

thanks so very much for your help.
I can see myself posting heaps more. JS is a challenge!
Thanks again
Michelle.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum