Here's basically what it does and how it works.
First we create the if part.
If the if is true then the code inside will be executed.
This looks like:
/*Define if, and give it a value.
if that value is true than the code will be executed
*/
if(x+a=y)
//here is your code to be used
{
document.write("This value is true")
}
Now, if your if is false, nothing is going to show up. So we can add else.Else, unlike if, doesn't need a value, so it just looks like:
else
{
document.write("The value was wrong")
}
Now there will always be something showing up on your page.If you want more than one value you can simply add more else:
else(s+7=9)
{
document.write("This is the extra else example")
}
So you could have a full code like:
if(x+a=y)
{
document.write("Value 1 is true")
}
else(x+a<y)
{
document.write("Value 2 is true")
}
else
{
document.write("All values are false")
This is my first tutorial and I hope you enjoyed this.
Edited by toxifyshadow, 18 March 2010 - 06:04 PM.
Added more


Sign In
Create Account


Back to top









