Hi All. I am using Microsoft Visual Web Developer 2010. I have embedded google maps into my webpage. I am using 4 textboxes: Street, City, Province and Postal Code. The user will enter these details then it will get put into a string variable like this string location = street + "," + "city" + "," + province + "," + postCode;

Now the google API code below uses this line for input: var input = document.getElementById('TextBox1');
I tried using var input = location; but it picked up syntax error. What can I do to fix this? Thanks.

Here is the source code below:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">

    function Initialize() {

        var mapOptions = {
            center: new google.maps.LatLng(-33.01, 27.9),
            zoom: 13,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        var map = new google.maps.Map(document.getElementById('GMap1'), mapOptions);

        **var input = document.getElementById('TextBox1');**
        var autocomplete = new google.maps.places.Autocomplete(input);
        autocomplete.bindTo('bounds', map);

        google.maps.event.addListener(autocomplete, 'place_changed', function () {

            var place = autocomplete.getPlace();
            if (place.geometry.viewport) {
            } else {

    google.maps.event.addDomListener(window, 'load', Initialize);


<input type="text" id="TextBox1">
        <div id="GMap1" style="height: 240px; width:570px" ></div>

Shouldn't you be passing input.value ?

Yeah thanks that worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.