Issue with passing js var value to a form element

Discussion in 'Javascript' started by DL, Jan 17, 2010.

  1. DL

    DL Guest

    Hi,

    I'm using google's client side tool that translate an IP into city and
    state. It works, however, don't know why such a simple js var value
    mapping to an form element failed in this case, that is, the js var
    {where}'s value failed to map to the value of the form element,
    'place'. Weird, I've something similar all the time, this time, it
    failed, am I blind? missing something obvious?

    Thanks.

    <html>
    <head>

    <script type="text/javascript" src="http://www.google.com/jsapi?
    key=ABQIAAAAp04yNttlQq-

    7b4aZI_jL5hQYPm-xtd00hTQOC0OXpAMO40FHAxQMnH50uBbWoKVHwgpklyirDEregg"></
    script>
    <script type="text/javascript">
    if(google.loader.ClientLocation)
    {
    visitor_city = google.loader.ClientLocation.address.city;
    visitor_region = google.loader.ClientLocation.address.region;
    visitor_country = google.loader.ClientLocation.address.country;
    where = visitor_city + ' ' + visitor_region;
    // alert(visitor_city);
    // alert(visitor_region);
    // alert(where);

    document.getElementById('loc').innerHTML= ' + where + ';
    // , ' + visitor_region;
    // , ' + visitor_country)';
    }
    // document.getElementById('location').value = document.getElementById
    ('loc').innerHTML;

    document.getElementById('place').value = ' + where + ';

    window.location.href="loc2.html";
    // document.location.href="location.html?l='+where";

    </script>
    </head>

    <body>

    <div id="loc"></div>
    <form>
    <input type="text" id="place">
    </form>

    </body>
    </html>
     
    DL, Jan 17, 2010
    #1
    1. Advertising

  2. DL

    DL Guest

    Never mind, I figured it out.

    >On Jan 16, 7:29 pm, DL <> wrote:
    > Hi,
    >
    > I'm using google's client side tool that translate an IP into city and
    > state.  It works, however, don't know why such a simple js var value
    > mapping to an form element failed in this case, that is, the js var
    > {where}'s value failed to map to the value of the form element,
    > 'place'.   Weird, I've something similar all the time, this time, it
    > failed, am I blind?  missing something obvious?
    >
    > Thanks.
    >
    > <html>
    > <head>
    >
    > <script type="text/javascript" src="http://www.google.com/jsapi?
    > key=ABQIAAAAp04yNttlQq-
    >
    > 7b4aZI_jL5hQYPm-xtd00hTQOC0OXpAMO40FHAxQMnH50uBbWoKVHwgpklyirDEregg"></
    > script>
    >         <script type="text/javascript">
    >                 if(google.loader.ClientLocation)
    >                 {
    >                         visitor_city = google.loader.ClientLocation.address.city;
    >                         visitor_region = google..loader.ClientLocation.address.region;
    >                         visitor_country = google.loader.ClientLocation.address.country;
    >                         where = visitor_city + ' ' + visitor_region;
    > // alert(visitor_city);
    > // alert(visitor_region);
    > // alert(where);
    >
    > document.getElementById('loc').innerHTML= ' + where + ';
    > // , ' + visitor_region;
    > // , ' + visitor_country)';
    >                 }
    > // document.getElementById('location').value = document.getElementById
    > ('loc').innerHTML;
    >
    > document.getElementById('place').value = ' + where + ';
    >
    > window.location.href="loc2.html";
    > // document.location.href="location.html?l='+where";
    >
    >         </script>
    > </head>
    >
    > <body>
    >
    > <div id="loc"></div>
    > <form>
    > <input type="text" id="place">
    > </form>
    >
    > </body>
    > </html>
     
    DL, Jan 17, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alvin Bruney

    Threads.. Session var lost, App var ok

    Alvin Bruney, Dec 2, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    381
    rooster575
    Dec 2, 2003
  2. thomson
    Replies:
    10
    Views:
    2,527
    Eliyahu Goldin
    Jun 20, 2005
  3. thomson
    Replies:
    0
    Views:
    404
    thomson
    Jun 20, 2005
  4. Fred
    Replies:
    3
    Views:
    340
    Alf P. Steinbach
    Aug 10, 2003
  5. Alex Vinokur
    Replies:
    4
    Views:
    491
    Ron Natalie
    Sep 24, 2003
Loading...

Share This Page