Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member 20GT's Avatar
    Join Date
    Jul 2015
    Posts
    48
    Member #
    50751

    basic math formula input page?

    Hi guys, I'm not a coder. I just play video games. what html code is used for a basic math formula input page.
    There are 2 inputs

    Code:
    latitude    (map coordinate - 50) * 13100
    longitude (map coordinate - 50) * 13100
    and the out put is
    Code:
    setplayerpos <latitude> <longitude> 200000
    the formula was take from here

    Thanks

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,018
    Member #
    27197
    Liked
    926 times
    You'll need 2 inputs and a button:
    HTML Code:
    <form action="#">
    <label for="lat"><input type="text" placeholder="latitude" name="lat" /></label>
    <label for="long"><input type="text" placeholder="longitude" name="long" /></label>
    <button class="gps_button">Calculate</button>
    </form>
    Then, you need a script to get the values and calculate them:
    HTML Code:
    <script>
    let button = document.querySelector('.gps_button');
    
    button.addEventListener('click', function(){
      let lat = parseFloat(document.querySelector('input[name=lat]').value) || 0;
      let long = parseFloat(document.querySelector('input[name=long]').value) || 0;
      
      lat = (lat - 50) * 13100;
      long = (long - 50) * 13100;
      
      alert('latitude: ' + lat + ' / longitude: ' + long);
    });
    </script>
    That should do it.
    Last edited by Ronald Roe; Oct 11th, 2017 at 11:34 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Member 20GT's Avatar
    Join Date
    Jul 2015
    Posts
    48
    Member #
    50751
    Do I name the script page calculate

  5. #4
    Member 20GT's Avatar
    Join Date
    Jul 2015
    Posts
    48
    Member #
    50751
    Thanks for the reply i really appreciate it

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>gps</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    let button = document.querySelector('.gps_button');
    
    button.addEventListener('click', function(){
      let lat = parseFloat(document.querySelector('input[name=lat]').value) || 0;
      let long = parseFloat(document.querySelector('input[name=long]').value) || 0;
      
      lat = (lat - 50) * 13100;
      long = (long - 50) * 13100;
      
      alert('latitude: ' + lat + ' / longitude: ' + long);
    });
    </script>
    
    </head>
    
    <body>
    <form action="#">
    <label for="lat"><input type="text" placeholder="latitude" name="lat" /></label>
    <label for="long"><input type="text" placeholder="longitude" name="long" /></label>
    <button class="gps_button">Calculate</button>
    </form>
    </body>
    </html>
    Im sure im doing it wrong but it doesn't seem to work

  6. #5
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,018
    Member #
    27197
    Liked
    926 times
    Try this:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>gps</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    window.addEventListener('load', function(){
    
      let button = document.querySelector('.gps_button');
    
      button.addEventListener('click', function(){
        let lat = parseFloat(document.querySelector('input[name=lat]').value) || 0;
        let long = parseFloat(document.querySelector('input[name=long]').value) || 0;
      
        lat = (lat - 50) * 13100;
        long = (long - 50) * 13100;
      
        alert('latitude: ' + lat + ' / longitude: ' + long);
      });
    
    });
    </script>
    
    </head>
    
    <body>
    <form action="#">
    <label for="lat"><input type="text" placeholder="latitude" name="lat" /></label>
    <label for="long"><input type="text" placeholder="longitude" name="long" /></label>
    <button class="gps_button">Calculate</button>
    </form>
    </body>
    </html>
    What's likely happening is the first line of it is firing before the form actually exists on the page. I wrapped a load event listener around it, which will stop that from happening.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  7. #6
    Member 20GT's Avatar
    Join Date
    Jul 2015
    Posts
    48
    Member #
    50751
    Works Great Thanks

  8. #7
    Member 20GT's Avatar
    Join Date
    Jul 2015
    Posts
    48
    Member #
    50751
    I adjusted it by copying and pasting with different variables but how do I make the result not disappear when I click to another page to copy the first number?

    WORKING GPS page

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>gps</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script>
    window.addEventListener('load', function(){
    
      let button = document.querySelector('.gps_button');
    
      button.addEventListener('click', function(){
        let lat1 = parseFloat(document.querySelector('input[name=lat1]').value) || 0;
        let long = parseFloat(document.querySelector('input[name=long]').value) || 0;
      
        lat1 = (lat1 - 50) * 13100;
        long = (long - 50) * 13100;
      
        alert('latitude: ' + lat1 + ' / longitude: ' + long);
      });
    
    });
    </script>
    
    </head>
    
    <body>
    <form action="#">
    <br><br>
    Ragnarok<br>
    <label for="lat1"><input type="text" placeholder="lat1itude" name="lat1" /></label>
    <label for="long"><input type="text" placeholder="longitude" name="long" /></label>
    <button class="gps_button">Calculate</button>
    </form>
    
    
    <script>
    window.addEventListener('load', function(){
    
      let button = document.querySelector('.gps1_button');
    
      button.addEventListener('click', function(){
        let lat1 = parseFloat(document.querySelector('input[name=lat1]').value) || 0;
        let long1 = parseFloat(document.querySelector('input[name=long1]').value) || 0;
      
        lat1 = (lat1 - 50) * 8000;
        long1 = (long1 - 50) * 8500;
      
        alert('latitude: ' + lat1 + ' / longitude: ' + long1);
      });
    
    });
    </script>
    
    </head>
    
    <body>
    <form action="#">
    <br><br>
    The Island<br>
    <label for="lat1"><input type="text" placeholder="latitude" name="lat1" /></label>
    <label for="long1"><input type="text" placeholder="longitude" name="long1" /></label>
    <button class="gps1_button">Calculate</button>
    </form>
    
    
    <script>
    window.addEventListener('load', function(){
    
      let button = document.querySelector('.gps2_button');
    
      button.addEventListener('click', function(){
        let lat2 = parseFloat(document.querySelector('input[name=lat2]').value) || 0;
        let long2 = parseFloat(document.querySelector('input[name=long2]').value) || 0;
      
        lat2 = (lat2 - 50) * 8000;
        long2 = (long2 - 50) * 8000;
      
        alert('latitude: ' + lat2 + ' / longitude: ' + long2);
      });
    
    });
    </script>
    
    </head>
    
    <body>
    <form action="#">
    <br><br>
    Scorched Earth<br>
    <label for="lat2"><input type="text" placeholder="latitude" name="lat2" /></label>
    <label for="long2"><input type="text" placeholder="longitude" name="long2" /></label>
    <button class="gps2_button">Calculate</button>
    </form>
    
    </html>
    </body>
    </html>


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:04 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com