1.

Solve : WHYY isn't this working??

Answer»

Code: [Select]<html>
<script type="text/javascript">

{

var x=20;
var y=10;
if x==20
{
document.write("TRUE STATEMENT");
}
else
{
document.write("FALSE STATEMENT");
}

}
</script>
</html>
Why is it not working?? Looks right to me.Wait, wait and wait.

Head over to W3Schools and learn HTML first. Then move onto CSS and finally javascript.I have already learnt HTML pretty much completely a while ago. And css I know a little of. I'm doing fine with Javascript so far...

Why is it not working? You want me to put it in of the text, or what are you trying to say here?A HTML doc needs at least a starting and ending html tag and a starting and ending body tag.

So yes, you need to put in tag.Thanks. OMG GUESS what I just noticed. I FORGOT to put the condition [if] in parentheses.
Whoops, javascript is so specific geez  Quote

I forgot to put the condition [if] in parentheses.
Errr.....

Quote
Code: [Select]<script type="text/javascript">

{

var x=20;
var y=10;
if x==20
{
document.write("TRUE STATEMENT");
}
else
{
document.write("FALSE STATEMENT");
}

}
</script>

You actually put in too many parentheses in there.

Unless it's a function which will be called later, you can use it this way:
Code: [Select]<script type="text-javascript">
var x=20;
var y=10;
if x==20
{
document.write("TRUE STATEMENT");
}
else
{
document.write("FALSE STATEMENT");
}
</script>

Quote
javascript is so specific geez
If that's the case, then FORGET what I said about learning PHP or ASP. Quote from: kpac on November 28, 2009, 03:49:32 PM
Errr.....

You actually put in too many parentheses in there.

Unless it's a function which will be called later, you can use it this way:
Code: [Select]<script type="text-javascript">
var x=20;
var y=10;
if x==20
{
document.write("TRUE STATEMENT");
}
else
{
document.write("FALSE STATEMENT");
}
</script>
If that's the case, then forget what I said about learning PHP or ASP.

Code: [Select]<script type="text-javascript">
var x=20;
var y=10;
if (x==20)
{
document.write("TRUE STATEMENT");
}
else
{
document.write("FALSE STATEMENT");
}
</script>

Do I not need parentheses around the condition? LIKE that.

if (x==20)

And I don't mind javascript being specific I actually like it, I just gotta get used to it, and stop making silly mistakes.... Quote
Do I not need parentheses around the condition? Like that.

if (x==20)
Woops sorry. Yes, I didn't notice that.
That's what happens when you're always copyin' 'n' pastin'.


Discussion

No Comment Found