Passing html 5 variable into input

This topic contains 1 reply, has 2 voices, and was last updated by  Paolo 8 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #133736

    urbanfix
    Expired Member
    Post count: 310

    I am trying to pass the users lattitude and longitude into the directions input on the tab the below code ads a button that requests the users location and displays it but i cant work out how to set it as a variable and echo it via php.
    I did echo the word cool though.

    
    
                   <?php if ($geodir_map_options['enable_map_direction']) { ?>
    
                        <input type="text" id="<?php echo $map_canvas_name; ?>_fromAddress" name="from" class="textfield"
                               value="<?php echo cool; ?>"
                               onblur="if (this.value == '') {this.value = '<?php echo ENTER_LOCATION_TEXT; ?>';}"
                               onfocus="if (this.value == '<?php echo ENTER_LOCATION_TEXT; ?>') {this.value = '';}"/>
                        <input type="button" value="<?php _e('Get Directions', 'geodirectory'); ?>"
                               class="<?php echo $map_canvas_name; ?>_getdirection" id="directions"
                               onclick="calcRoute('<?php echo $map_canvas_name; ?>')"/>
                       <button onclick="getLocation()">Near Me</button>
    <p id="demo"></p>
    
    <script>
    var x = document.getElementById("demo");
    
    function getLocation() {
        if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(showPosition);
        } else { 
            x.innerHTML = "Geolocation is not supported by this browser.";
        }
    }
    
    function showPosition(position) {
        x.innerHTML = position.coords.latitude +","+ position.coords.longitude;	
    }
    </script>
                        <script>
                            <?php if(geodir_is_page('detail')){?>
                            jQuery(function () {
                                gd_initialize_ac();
                            });

    Any help would be great from anyone! Thankyou 🙂

    #134029

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I can move this in the jobs section of the forum if you wish, this is beyond support.

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket