Results 1 to 7 of 7

Thread: Step by step with JavaScript

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Step by step with JavaScript

    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

  2. #2
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    what I know are theese commands:
    PHP Code:
    document.write(x); - for writing value or wordvariable also possible.
    if... else 
    statements and maybe more.... 
    BUT,

    What is that and why we use it?

    PHP Code:
    e=(condition)?value1:value2 
    or
    PHP Code:
    greeting=(visitor=="PRES")?"Dear President ":"Dear "
    AND this progam

    PHP Code:
    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?

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    PHP Code:
    e=(condition)?value1:value2 
    or
    PHP Code:
    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/Cor...cial_Operators

    AND this progam

    PHP Code:
    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/Cor...tements/switch

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

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

  4. #4
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    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.

  5. #5
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    PHP variable to JavaScript:

    PHP Code:
    <?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.

  6. #6
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    Thanks.

    OK, more

    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
    Last edited by auriaks; 02-19-2010 at 11:19 PM.

  7. #7
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    anything??

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •