www.webdeveloper.com
Results 1 to 3 of 3

Thread: Help with conversion

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    5

    Help with conversion

    This is what I have so far, the directions state "Create a page in which you have a form that asks the user to enter an amount in meters. When they click the button, your form should retrieve that value and convert it into feet. The conversion is 1 meter = 3.28 feet. Have variables to store each (feet and meters). Then output (in an alert box), the result in feet." So basically I can't figure out how to ask user to input X amount and then include that in the function.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Meters to feet conversion</title>

    <script type="text/javascript">
    function metersToFeet()
    {
    var meters;
    var feet;

    amountOfMeters = prompt("Give me a number.", "");
    total = (amountOfMeters * 3.28);

    alert(total);
    }
    </script>
    </head>

    <body>

    <head>
    <h1>Convert meters to feet</h1>
    <hr>

    <input type="button" value="Convert meters to feet"
    name="btnSubmit" onclick="metersToFeet()">
    </body>
    </html>

  2. #2
    Join Date
    Oct 2013
    Location
    Kalyan , Mumbai , India
    Posts
    4
    create a input of type text in which user put values.
    then on button click grab that input value and convert that value in feet and alert that value.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Meters to feet conversion</title>

    <script type="text/javascript">
    function metersToFeet()
    {
    var meters = document.getElementById("ipNumber").value;
    var feet;


    var total = (meters* 3.28);

    alert(total);
    }
    </script>
    </head>

    <body>

    <h1>Convert meters to feet</h1>
    <hr>
    Enter a number : <input type="text" id="ipNumber" /><br/>
    <input type="button" value="Convert meters to feet"
    name="btnSubmit" onclick="metersToFeet()">
    </body>
    </html>



    check out this Fiddle http://jsfiddle.net/QMAAS/ for demo

  3. #3
    Join Date
    Oct 2013
    Posts
    5
    Wow, thank you so much!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles