Show variable in textbox

Discussion in 'JavaScript' started by s.draaisma@globalhome.eu, Jan 22, 2007.

  1. #1
    Hi, I'm new to this forum and have not much experiance with JS. I'm trying to get 2 variables showing up in 2 text boxes, but without results.

    I know the variables contain their data because I created a (test) alert box showing the variables, and that works. Its just that they don't show up in the text boxes.

    The link to the page is http://www.globalhome.eu/new_object_v2.2.php
    (live link is not available for me as a newbee, I'm sorry for that)
    The variables are called:
    lat
    lng


    All help is apreciated!

    Kind regards,
    Sebastiaan
     
  2. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This should answer your question.

    
    <label>latitude
    	<input type="text" name="latitude" id="lat">
    </label>
    <label>longtitude
    	<input type="text" name="longtitude" id="lng">
    </label>
    
    <script type="text/javascript">
    var lng = 5;
    var lat = 15;
    document.getElementById("lat").value= lat;
    document.getElementById("lng").value= lng;
    </script>
    
    Code (markup):
     
    giraph, Jan 22, 2007 IP
  3. s.draaisma@globalhome.eu

    s.draaisma@globalhome.eu Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you Giraph for your reply!
    I must be doing something wrong as it doesn't work for me :confused:

    The updated version with your script can be seen at:
    http://www.globalhome.eu/new_object_v2.3.php

    Kind regards,
    Sebas.
     
  4. s.draaisma@globalhome.eu

    s.draaisma@globalhome.eu Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi Giraph,
    It does work (got it to work). I had the variables called before they where created ;)

    By simply changing the position of your solution it worked!

    Thanks again!
    Kind regards,
    Sebas.
     
  5. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Glad you got that figured out =].
     
    giraph, Jan 23, 2007 IP