PDA

View Full Version : having 2 'else' in one script


vkidv
09-05-2002, 04:38 PM
hey,
sounds stupid but im not that great at writing my own javascripts, i copy and paste snipets of others and put them into mine (im not a good speller).

please could anybody tell me to have more than one else in a script - i think its somthing to do with { and }
here is an example, i got bored and started making a little chat alert person::

<script>
alert("hi, im rob the robot")
talk=confirm("do you want to talk to me?")
if (talk == true)
alert("yay")

else
alert("ok..bye")
</script>

how do i add some questions into this - so i dont just have 1 else!
thanx - simple to you, confusing to me
:P

x_goose_x
09-05-2002, 04:53 PM
I'm guessing you mean...

if (day=="monday") {

}
else if (day=="tuesday") {

}
else if (day=="wednesday") {

}
else {

}

vkidv
09-05-2002, 04:57 PM
ok im guessing..



if (day=="monday") {
<if the date was monday id put what i want to happen here>
}
else if (day=="tuesday") {
<if the date was not monday id put what i want to happen here>
}
else if (day=="wednesday") {
<if the date was not monday id put what i want to happen here>
}
else {
<if the date was not monday id put what i want to happen here>
}


do i put what i want to happen , between the { and } ect?

x_goose_x
09-05-2002, 05:01 PM
yes

vkidv
09-05-2002, 05:02 PM
thanx goose :P
ur online!

hi

x_goose_x
09-05-2002, 05:04 PM
You might also want to try http://www.devguru.com/Technologies/ecmascript/quickref/switch.html It's a bit more complex, but when you get into much more options, it can simplify things.