Jump to content

Leon

Members
  • Posts

    18
  • Joined

  • Last visited

Posts posted by Leon

  1. Hi im new to css. Im trying to get the nav bar into the center of the header image. For some reason im following the tutorial online step by step and still doesnt work.

     

     

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Nav Bar and Header</title>
    <link rel="stylesheet" type="text/css" href="navbar.css"/>
    </head>
    <body>
    <div id="nav">
    <div id="nav_wrapper"> <br>
    <ul>
    <li><a href="#">Home Menu</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">Contact</a></li>
    </ul>
    </div>
    </div>
    </body>
    </html>
    This is my code。
    if code was written :
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Nav Bar and Header</title>
    <link rel="stylesheet" type="text/css" href="navbar.css"/>
    </head>
    <body>
    <div id="nav">
    <li><a href="#">Home Menu</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">Contact</a></li>
    <div id="nav_wrapper"> <br>
    <ul>
    <li><a href="#">Home Menu</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">Contact</a></li>
    </ul>
    </div>
    </div>
    </body>
    </html>
    it will happen image one. Is there a way to move the

     

    post-190011-0-86047400-1463880659_thumb.jpg

    post-190011-0-41447800-1463880660_thumb.jpg

    post-190011-0-89886700-1463880660_thumb.jpg

  2. BUT! in doing that, you have to replace every reference to start with go.

    the most importantly it was "start=setInterval("start()",400);" i have to change it to go=setInterval("turn()",400);

     

    this is the part where i ignored. im sorry for wasting your time.

    But thankyou for everything

  3. Any variable declared within a function without starting with var is global and accessible outside and inside the function as though it was declared outside the function starting with var. That is why variable start is always working.A variable declared in function starting with var is only accessible within that function.var go; is just declaring a varible, it has no value, method, function, absolutely nothing applied to it later on within the script, yet you are testing for a value in the if condition which will ALWAYS be false because it has a empty, null value.That it! If you don't get now i should give it up.

    the most importantly it was "start=setInterval("start()",400);" i have to change it to go=setInterval("turn()",400);

    thanks
  4. Any variable declared within a function without starting with var is global and accessible outside and inside the function as though it was declared outside the function starting with var. That is why variable start is always working.A variable declared in function starting with var is only accessible within that function.var go; is just declaring a varible, it has no value, method, function, absolutely nothing applied to it later on within the script, yet you are testing for a value in the if condition which will ALWAYS be false because it has a empty, null value.That it! If you don't get now i should give it up.

    well, i can always rename to var start as var go

    for example :

    post-190011-0-76032100-1447032878_thumb.png

    this is how i look at the code

  5. Terrible code. Why would you be testing a variable when you never gave it a value? Also you use the variable 'start' without declaring it.

    im just following my professor example. THATS WHY IM CONFUSE.. var start doesnt have a declare but it works but var go doesnt ...

  6. The first one, the others won't because var go; is just declaration of empty var with no value, any reference to it will be empty nul value. Just compare it to all refereces of start, where if you look CAREFULLY it is assigned a specific method that runs a specific function (alert big clue here).

    sorry for saying this but i did compare it ...

     

    i still dont see it... can u point out the code for me ..

  7. It works OK! in better browsers, with crappy IE it fails as usual, maybe clearInterva() is overridden by setInterval() as it loops and IE being slow can't initiate clearInterval() in time, suggest you create new function and use clearInterval() within that to stop animation and remove if(start) condition.

    which one it works ? the one with var start; ?

    if the one with var start; works then why wouldnt the one with var go; doesnt work ? They are identical.

  8. You are changing it to a variable that has no value applied to it, so it is null.If it is null the if condition will be false it will be ignored.

    a variable that has no value applied to it? can you show me an example ? please?

    a variable that has no value applied to it? can you show me an example ? please?

  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <script language="javascript">
    var smile = new Array(6);
    var rotate=0;
    var start;
    smile [0]= new Image();
    smile [0].src="smile0.jpg";
    smile [1]= new Image();
    smile [1].src="smile1.jpg";
    smile [2]= new Image();
    smile [2].src="smile2.jpg";
    smile [3]= new Image();
    smile [3].src="smile3.jpg";
    smile [4]= new Image();
    smile [4].src="smile4.jpg";
    smile [5]= new Image();
    smile [5].src="smile5.jpg";
    function turn(){
    if(rotate==5)
    rotate=0;
    else
    ++rotate;
    document.smile.src=smile[rotate].src;
    }
    function turningpoint() {
    if (start)
    clearInterval(start);
    start=setInterval("turn()",400);
    }
    </script>
    <p><img src="smile0.jpg" name="smile"/> </p>
    <form>
    <input type="button" name="run" value=" Run " onclick="turningpoint();"/>
    <input type="button" name="Stop" value=" Stop " onclick="clearInterval(start);"/>
    </form>
    </body>
    </html>

     

    I am trying to do a debug on this code but i cant find any errors. I have a few questions about this code.

    1) "Sometime it works on desktop but not on expression web.

    2) when i rename It has nothing to do with ''var Start" to other names it doesnt work. The stop button doesnt work.

    For example :

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <script language="javascript">
    var smile = new Array(6);
    var rotate=0;
    var begin;
    smile [0]= new Image();
    smile [0].src="smile0.jpg";
    smile [1]= new Image();
    smile [1].src="smile1.jpg";
    smile [2]= new Image();
    smile [2].src="smile2.jpg";
    smile [3]= new Image();
    smile [3].src="smile3.jpg";
    smile [4]= new Image();
    smile [4].src="smile4.jpg";
    smile [5]= new Image();
    smile [5].src="smile5.jpg";
    function turn(){
    if(rotate==5)
    rotate=0;
    else
    ++rotate;
    document.smile.src=smile[rotate].src;
    }
    function turningpoint() {
    if (begin)
    clearInterval(begin);
    start=setInterval("turn()",400);
    }
    </script>
    <p><img src="../5/smile0.jpg" name="smile"/> </p>
    <form>
    <input type="button" name="run" value="Run" onclick="turningpoint();"/>
    <input type="button" name="Stop" value="Stop" onclick="clearInterval(begin);"/>
    </form>
    </body>
    </html>
    OR
    when i rename function turn() to function start() the run button doesnt function
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <script language="javascript">
    var smile = new Array(6);
    var rotate=0;
    var go;
    smile [0]= new Image();
    smile [0].src="smile0.jpg";
    smile [1]= new Image();
    smile [1].src="smile1.jpg";
    smile [2]= new Image();
    smile [2].src="smile2.jpg";
    smile [3]= new Image();
    smile [3].src="smile3.jpg";
    smile [4]= new Image();
    smile [4].src="smile4.jpg";
    smile [5]= new Image();
    smile [5].src="smile5.jpg";
    function start(){
    if(rotate==5)
    rotate=0;
    else
    ++rotate;
    document.smile.src=smile[rotate].src;
    }
    function turningpoint() {
    if (go)
    clearInterval(go);
    start=setInterval("start()",400);
    }
    </script>
    <p><img src="../5/smile0.jpg" name="smile"/> </p>
    <form>
    <input type="button" name="run" value="Run" onclick="turningpoint();"/>
    <input type="button" name="Stop" value="Stop" onclick="clearInterval(go);"/>
    </form>
    </body>
    </html>

    post-190011-0-18973500-1446949823_thumb.jpg

    post-190011-0-73556200-1446949823_thumb.jpg

    post-190011-0-23399800-1446949824_thumb.jpg

    post-190011-0-84570800-1446949824_thumb.jpg

    post-190011-0-13977700-1446949825_thumb.jpg

    post-190011-0-42331900-1446949825_thumb.jpg

  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <script language="javascript">
    var smile = new Array(6);
    var rotate=0;
    var start;
    smile [0]= new Image();
    smile [0].src="smile0.jpg";
    smile [1]= new Image();
    smile [1].src="smile1.jpg";
    smile [2]= new Image();
    smile [2].src="smile2.jpg";
    smile [3]= new Image();
    smile [3].src="smile3.jpg";
    smile [4]= new Image();
    smile [4].src="smile4.jpg";
    smile [5]= new Image();
    smile [5].src="smile5.jpg";
    function turn(){
    if(rotate==5)
    rotate=0;
    else
    ++rotate;
    document.smile.src=smile[rotate].src;
    }
    function turningpoint() {
    if (start)
    clearInterval(start);
    start=setInterval("turn()",400);
    }
    </script>
    <p><img src="smile0.jpg" name="smile"/> </p>
    <form>
    <input type="button" name="run" value=" Run " onclick="turningpoint();"/>
    <input type="button" name="Stop" value=" Stop " onclick="clearInterval(start);"/>
    </form>
    </body>
    </html>

    10.html

    post-190011-0-12626200-1446759522_thumb.jpg

    post-190011-0-62125400-1446759522_thumb.jpg

    post-190011-0-92291000-1446759522_thumb.jpg

    post-190011-0-16482300-1446759523_thumb.jpg

    post-190011-0-41196300-1446759523_thumb.jpg

    post-190011-0-66142900-1446759523_thumb.jpg

  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>
    <body>
    <form name="checkmail" onSubmit="return checkemail()" method="post"
    action="javascript:alert('The form is submitted!!!')">
    Please enter your email<br />
    <input name="Text1" type="text" />
    <input name="Button1" type="submit" value="submit" />
    </form>
    <script language="javascript" >
    function checkemail(){
    var email=document.checkmail.Text1.value;
    if (email.indexOf(' ')==-1
    && 0 < email.indexOf('@')
    && email.indexOf('@')+5< email.length
    )return true;
    else alert('Invalid Email address')
    return false;
    }
    </script>
    </body>
    </html>
    if (email.indexOf(' ')==-1
    && 0 < email.indexOf('@')
    && email.indexOf('@')+5< email.length
    )return true;
    else alert('Invalid Email address')
    return false;
    }
    Can someone tell me what does this part of code do? i have look through w3cschool and i dont understand.

     

  12. 1)
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 2</title>
    </head>
    <body>
    <p>Current Time</p>
    <p id="CurrentTime"></p>
    <script>
    var myVaribale=setInterval(thetimeisnow,1000);
    function thetimeisnow(){
    var y=new Date();
    document.getElementById("CurrentTime").innerHTML=y;
    }
    </script>
    </body>
    </html>

     

     

     

     

     

    2)

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 2</title>
    </head>
    <body>
    <p>Current Time</p>
    <p id="CurrentTime"></p>
    <script>
    var myVaribale=setInterval(thetimeisnow,1000);
    function thetimeisnow(){
    var y=new Date();
    document.getElementById("CurrentTime").innerHTML=y.toLocaleDateString();
    }
    </script>
    </body>
    </html>

     

     

     

    "The first code, i can display time and date but idk how to change the time zone. The second one if i include "toLocaleDateString();"it will be display only date not the time.. if without"toLocaleDateString();" it will display the output on the first image can someone tell me why? "

    post-190011-0-94476600-1445483464_thumb.png

    post-190011-0-74105500-1445484106_thumb.png

  13.  

    Final code? You don't even have closing tags...

    </body></html>

    LOL i got too excited that i had it works, forgot to copy the last two tags

     

     

     

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

    <title>Cmftin</title>

    </head>

    <body>

    <h1>This method will change metric to standard.</h1>

    <form action="" name="centimeter" >

    Centimeter<input type="text" name="cm" value="0" />

    Feet<input type="text" name="ft" value="0" />

    Inch<input type="text" name="in" value="0" />

    </form>

    <input name="Button1" type="button" value="convert" onclick="crtcm2ftin ()" />

    <script type="text/javascript">

    function crtcm2ftin (){

    var cm= parseInt(document.centimeter.cm.value);

    if (cm > 0){

    var ft= (cm/30.48);

    document.centimeter.ft.value=ft;

    var inch = (cm/2.54);

    document.centimeter.in.value=inch;

    }

    }

    /*Leon*/

    </script>

    <p> </p>

    </body>

    </html>

  14. 1) You just need a single parent <form>...</form> to wrap all inputs

    2) You you don't have a method to prevent form submission, when the submit button is pressed it will reload and all content will be lost each time.

    3) The onclick used in submit should be applied to form element using onsubmit="Submit1"

    4) what does 'Submit1', 'cncm2ft' in document.cncm2ft.feet.value= feet, 'result', and 'x' refer to? it feels like this is just part of the code, difficult to help fully in this situation.

    5) make sure to place a space between each attribute and value, this 'name="inch"value="0" ' should be 'name="inch" value="0" '

    6) missing closing script tag, but probably because this is just part of code and not the full code,

     

    7) wrap code using code button '<>' (in menu) or manually

    ['code']' ...your code here... ['/code'] without quotes

    '

    to make it easier to read.

     

    Use form elements collection instead http://www.w3schools.com/jsref/coll_form_elements.asp much more easier, on onchange event call function, use for loop to loop through each input except submit ( if required? ) to retrive each input value and make calculation.

    Ty so much , u helped me a lot.

    This is my final code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>Cmftin</title></head><body><h1>This method will change metric to standard.</h1><form action="" name="centimeter" >Centimeter<input type="text" name="cm" value="0" />Feet<input type="text" name="ft" value="0" />Inch<input type="text" name="in" value="0" /></form><input name="Button1" type="button" value="convert" onclick="crtcm2ftin ()" /><script type="text/javascript">function crtcm2ftin (){var cm= parseInt(document.centimeter.cm.value);if (cm > 0){var ft= (cm/30.48);document.centimeter.ft.value=ft;var inch = (cm/2.54);document.centimeter.in.value=inch; }}</script><p> </p>
  15. 1) You just need a single parent <form>...</form> to wrap all inputs

    2) You you don't have a method to prevent form submission, when the submit button is pressed it will reload and all content will be lost each time.

    3) The onclick used in submit should be applied to form element using onsubmit="Submit1"

    4) what does 'Submit1', 'cncm2ft' in document.cncm2ft.feet.value= feet, 'result', and 'x' refer to? it feels like this is just part of the code, difficult to help fully in this situation.

    5) make sure to place a space between each attribute and value, this 'name="inch"value="0" ' should be 'name="inch" value="0" '

    6) missing closing script tag, but probably because this is just part of code and not the full code,

     

    7) wrap code using code button '<>' (in menu) or manually

    ['code']' ...your code here... ['/code'] without quotes

    '

    to make it easier to read.

    but when i use a single <form>...</form> i cant not initialized feet or inch in (document.cncm2ft.feet.value) or ( document.cncm2ft.inch.value)

  16. <head>
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Converting Centimeter to Feet Centimeter to Inch</title>
    </head>
    <body>
    <h1>This method will change metric to standard.</h1>
    <p>Centimeter</p>
    <form action="" name="cvrtcm2ft2in()">
    <input type="text" name="cm" value="0" onchange="cvrtcm2ft2in()"/><input onclick="Submit1" type="submit" value="submit" /></form>
    <form action="" name="cvrtcm2ft2in()">
    <p>Feet</p>
    <input type="text" name="feet" value="0" onchange="cvrtcm2ft2in()"/></form>
    <form action="" name="cvrtcm2ft2in()">
    <p>Inch</p>
    <input type="text" name="inch"value="0" onchange="cvrtcm2ft2in()"/></form>
    <script type="text/javascript">
    function cvrtcm2ft2in(){
    var cm=parseInt(document.cncm2ft.cm.value);
    if (cm>0){
    var ft= x/30.58;
    document.cncm2ft.feet.value= feet;
    var figs = "The CM representation of " + x + " is " + cm +"<br>";
    document.getElementById("result").innerHTML = figs;
    }
    So far im trying get cm convert to feet, but i dont know why when i input a value and nothing come out
    I need a solution asap.
    I have found a few online but i dont want to copy , i want to write my own. Please help :fool:
×
×
  • Create New...