Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help with basic html

    Im currently stuck with a converting Celsius into Fahrenheit project, my teacher made us use a template to make it and im very confused on where to put what, would greatly appreciate any help i can get, i will copy and paste the instructions and what i have so far, thanks for any who help:

    INSTRUCTIONS: http://www.docdroid.net/77by/c2fconv...ment5.pdf.html

    WHAT I HAVE:
    <html>
    <head>
    <title>
    COMSC100-3080 Assign.5 by Carl Sanchez - 1235441
    </title>

    <script>
    // copy/paste the following three lines after the script tag in EVERY program
    function getInputAsText(_id){return document.getElementById(_id).value}
    function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)}
    function setOutput(_id, _value){document.getElementById(_id).value = _value}

    function calculate()
    {

    }
    </script>
    </head>
    <body>

    </body>
    </html>

  • #2
    New to the CF scene
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    *Bump*

    i also have teamviewer and mumble if you would like to walk me through this assignment, thanks

  • #3
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,760
    Thanks
    23
    Thanked 546 Times in 545 Posts
    Your link does not work. It looks like they want you to get your input to the calculate() function by calling other functions like this
    Code:
    ....
    
    function calculate()
    {
    	var F = getInputAsNumber("f")* 9 / 5 + 32;
    ....  and other stuff ...
    }
    </script>
    </head>
    <body>
    <input id="f" name="f"> degrees Fahrenheit<br />
    <button name="Sub" value="PUSH" onclick="calculate();">Results</button>
    </body>
    Evolution - The non-random survival of random variants.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,455
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Script tags go just before the </body> tag.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,760
    Thanks
    23
    Thanked 546 Times in 545 Posts
    Quote Originally Posted by felgall View Post
    Script tags go just before the </body> tag.
    Not really written in stone. If the contents are all functions does it matter?
    Evolution - The non-random survival of random variants.

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,455
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Quote Originally Posted by sunfighter View Post
    Not really written in stone. If the contents are all functions does it matter?
    if all of your JavaScript is functions then there's no point attaching it at all as functions by themselves will never run.

    Some of the JavaScript has to be run in order to call the functions and that JavaScript is best placed at the bottom of the page so that the HTML it references exists before it tries to run. It can run sooner when attached at the bottom than it can if attached inside an onload handler at the top. It certainly shouldn't be jumbled in with the HTML.

    Also placing the JavaScript at the bottom makes the page appear to load faster as the display of the content isn't delayed while the JavaScript loads. The easiest way to make a web page appear to load faster when the JavaScript is in the head or jumbled in with the HTML is to move it all to the bottom.
    Last edited by felgall; 12-16-2013 at 09:30 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #7
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,760
    Thanks
    23
    Thanked 546 Times in 545 Posts
    Also placing the JavaScript at the bottom makes the page appear to load faster as the display of the content isn't delayed while the JavaScript loads. The easiest way to make a web page appear to load faster when the JavaScript is in the head or jumbled in with the HTML is to move it all to the bottom.
    OK That makes sense. Faster loading of page.

    In the above the JS is in the head due to sirgoodkat's assignment, it is all functions and they are called by an onclick that I placed in the body. Don't think that is wrong, just against good practices. And I do agree with that. But teachers want what teachers want, good practices or not.
    Evolution - The non-random survival of random variants.

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,455
    Thanks
    0
    Thanked 632 Times in 622 Posts
    Quote Originally Posted by sunfighter View Post
    But teachers want what teachers want, good practices or not.
    I'll agree with that - most students asking for help with JavaScript on forums seem to have teachers who think Netscape 4 is the latest and greatest browser - at least in so far as the way they want the JavaScript written is concerned. Unfortunately the students then end up thinking that the way Javacript had to be written to work with Netscape 4 back in the 20th Century is the way to write it today where in fact the language is now very different. Those students will need to take a JavaScript programming course if they want to learn how to write JavaScript properly and unfortunately the JavaScript history they have been taught will just make that more difficult.

    It's always worth letting the student know the difference as in some cases they might be able to drop the JavaScript history course and learn something useful instead.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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