[x]

See Where You Rank in Washington

  1. So i must have missed the class we went over java cuz im lost. this is what i have so far :

    <html>
    <body>

    <title> Fahrenheit to Celsius Converter </title>

    <p> Assignment: #3 </P>


    <hr>
    <h1> Welcome to the "Fahrenheit to Celsius" temperature scale converter </h1>
    Please enter the remperature in Fahrenheit scale:

    <script language="JavaScript" type="text/javascript">






    <body>
    </html>


    Any and all help would be appreciated. Im trying to look around online and can't grasp what and why people are doing what. basically though I need to have a box on the page where you enter the degree in fahrenheit, have two buttons below it saying "clear form" or "click to see results" which bring up the next page that shows it in celsius. Also, I need to have 2 error buttons, one if the field is left blank, and another if the field has text instead of a number

    Again, any help is really appreciated, im pretty lost lol
     
  2. Does it have to be Java? Java = old school. No clue how to do it in Java, but php is easy.
  3. The most help I can offer here is telling you that you spelled temperature wrong in the 7th line
  4. Here is something that might help start you off:


    <!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>
    <script language="JavaScript">

    function ToC()
    {
    var strIn = document.tempform.temp.value;

    if(isNaN(strIn))
    {
    alert("Not a Number");
    }
    else
    {
    var f = parseFloat(strIn);
    var c = (f - 32) * 5/9;

    var r = Math.round(c * 100)/100;
    document.tempform.temp.value = r.toString();
    }
    }

    function ToF()
    {
    var strIn = document.tempform.temp.value;

    if(isNaN(strIn))
    {
    alert("Not a Number");
    }
    else
    {
    var c = parseFloat(strIn);
    var f = (c * 9/5) + 32;

    var r = Math.round(f * 100)/100;
    document.tempform.temp.value = r.toString();
    }
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>

    </head>

    Fahrenheit to Celsius / Celsius to Fahrenheit Converter<br>
    <form name="tempform">
    <input type="text" name="temp" style="text-align:right" size=4 maxlength=6>
    <input type="button" value="To Celsius" onclick="ToC()">
    <input type="button" value="To Fahrenheit" onclick="ToF()">
    </form>

    <body>
    </body>
    </html>



    You have to have the java code in between the <head> </head> tags . So if you want to tweak anything just make sure the form is below the code.
    Edited By: Hateflops Mar 7th, 2012 at 10:26 PM
  5. yea i was browsing w3schools for help and still couldn't figure anything out really. The problem is that most of the help I can find just have a converter on the page. I need to be able to type in fahrenheit on the first page and have it go to a second page where it will give you the celsius

    ok heres where im at now. I have the layout correct, so now i just need help with the formula. Ive tried a few times to use help from w3 but its not working.

    <html>
    <body>

    <title> Fahrenheit to Celsius Converter </title>



    <p> Assignment: #3 </P>


    <hr>
    <h1> Welcome to the "Fahrenheit to Celsius" temperature scale converter </h1>


    <script language="JavaScript" type="text/javascript">



    </script>

    <p>
    Please enter the temperature in Fahrenheit scale:
    <input type="text" name="temp" style="text-align:right" size=4 maxlength=6> <br>
    <input type="button" name="show_results" value="Click to show results" onClick="check_the_numbers()" >
    <input type="reset" name="Reset" value="Clear form">
    </p>


    <body>
    </html>
    Edited By: quietwinner Mar 7th, 2012 at 10:42 PM
     
    Thread Starter
  6. I use the rule of thumb, ( F -32)
    -----------
    2

    72 -32 = 40 divided by 2 = 20 celcius.
  7. any other help?

    after i open <source> im clueless. Looking stuff up on google looks like chinese to me. i think i have to start with like function FtoC and then have like 2 variables and then include error messages, but have 0 clue how to do it...
     
    Thread Starter
  8. Make page 1 verify the value and display an error if it isn't a valid entry. In the case of a valid entry then pass the entry onto the second page through the url (replace VALUE with the entered number) such as this yourURL\tempconverter.html?temp=VALUE. Page 2 would look like this:

    <html>
    <head>
    <script type="text/javascript">
    function getUrlParams( name )
    {
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    var regexS = "[\\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
    if( results == null )
    return "";
    else
    return results[1];
    }

    function convertTemp()
    {
    var a = getUrlParams('temp');
    return ((a - 32) * 5/9);
    }
    </script>
    </head>

    <body>
    <script type="text/javascript">
    document.write(convertTemp());
    </script>

    </body>
    </html>
  9. so thats my second page, i still have no clue how to do the first page?

    and im not sure that i need like a completely new notepad, im pretty sure the assignment is for one html document. so is there a way for you to input a number and hit calculate and without having a 2nd html document have a different or new page come up?

    im just unsure like what my function should be, is it just function FtoC? and then have { and then im just lost what comes after that. I know variables need to be in there and if and return and stuff, just have 0 clue how to use them
     
    Thread Starter
  10. Hateflops code works if you just need a temp converter on a single page. Is it required that that clicking submit or whatever causes a page reload? If yes, you'd have to use the url parser to check if there is a parameter. If there is then you display the converted temp, if not then display the textbox and buttons for submitting a temperature. If you really want to learn this, I suggest following tutorials. It isn't that hard to modify the code that they provide to come up with working solutions. You're next assignment will be harder to do if you don't learn this one.
  11. yea i need when you click submit that the pages reloads and basically just says temperature of 32 degrees fahrenheit is equal
    to: 0 degrees celsius

    and then a link below that that says "click here to go back"

    Ive tried going through tutorials but I just don't understand what most of it means. Thats why i posted here. And I dont care about learning it, this is the only java hw for this class, so not too worried about actually understanding
     
    Thread Starter
  12. Wow, i completely forgot that at some point in my life i knew how to do this. That was 2003-04 tho.

    I dont envy you. Fuck that shit.

    Good luck. Sorry for the false hope bump when you see this lol.
  13. bastard. yea java blows ass, html is really easy tho. doesn't matter much its a group project and im hoping my group members are gonna come though lol
     
    Thread Starter