PDA

View Full Version : Step by step with JavaScript



auriaks
02-09-2010, 11:42 PM
Hi,
I am junior at JavaScript :) But I am trying to learn more about it.

So, the main idea of this topic is that I have read some articles/tutorials about JavaScript, but all I know is how to write or show something in the page.

But how to make slides, or nice animation? It is deep hole for me, so I ask for your help. Just write here step by step tutorials with pictures or something valuable. I know that JavaScript is really powerful language in website advance.

Thanks for your time spending on this and sorry for my grammar :)

auriaks
02-09-2010, 11:48 PM
what I know are theese commands:

document.write(x); - for writing value or word. variable also possible.
if... else statements and maybe more....

BUT,

What is that and why we use it?


e=(condition)?value1:value2 or
greeting=(visitor=="PRES")?"Dear President ":"Dear ";

AND this progam


var d=new Date();
theDay=d.getDay();
switch (theDay)
{
case 5:
document.write("Finally Friday");
break;
case 6:
document.write("Super Saturday");
break;
case 0:
document.write("Sleepy Sunday");
break;
default:
document.write("I'm looking forward to this weekend!");
}

Break? case? default?

boogyman
02-10-2010, 04:35 PM
e=(condition)?value1:value2 or
greeting=(visitor=="PRES")?"Dear President ":"Dear ";

This is called a tertiary operator and works the same way an IF/ELSE loop works, without the additional syntax.
https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Operators/Special_Operators



AND this progam


var d=new Date();
theDay=d.getDay();
switch (theDay)
{
case 5:
document.write("Finally Friday");
break;
case 6:
document.write("Super Saturday");
break;
case 0:
document.write("Sleepy Sunday");
break;
default:
document.write("I'm looking forward to this weekend!");
}

Break? case? default?

This is another type of loop called a switch statement, and again is similar to an IF/ELSE loop.
https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/switch

If you have any specific questions, please do not hesitate to ask.

Some other helpful "JS basics"
http://www.howtocreate.co.uk/tutorials/javascript/dombasics
https://developer.mozilla.org/en/JavaScript

auriaks
02-11-2010, 05:58 PM
OK, new thing:

I have $myfriendname variable, but I need it in javascript... Is it possible to convert it to javascript variable "myfriendname" or make them equal?

The same question about converting javascript variable "lessons" to php variable $lessons.

Schmoopy
02-11-2010, 06:10 PM
PHP variable to JavaScript:



<?php
$myfriendname = 'Chuck';
?>
<script type="text/javascript">
var myfriendname = '<?php echo $myfriendname; ?>';
alert(myfriendname); // Outputs Chuck
</script>


JavaScript variable to PHP variable is more difficult, because after a page has loaded, you can no longer do anything with the php code, unless you use AJAX, or submit a form or something similar.

Depends what you want to do with it.

auriaks
02-11-2010, 06:22 PM
Thanks.

OK, more :D

I always wanted to make animations to my menu with JavaScript. Maybe you can recommend some sites/tutorials of this only? Or you can teach me something?
sliding objects, color changing in time period, etc...

Thanks :)

auriaks
02-19-2010, 11:21 PM
anything??