Jump to content

Recommended Posts

I accidently marked my previous thread as solved but I have another query.

 

I am now tring to implement the Google Maps API. I am currently pulling a postcode from a databse into a table. What I need to do is allow a user to click on that postcode which links onto the maps page and populates the postcode textbox and submits automatically.

 

Address page:

        <table border="black">
            <tr>
                <th>Postcode</th>
                <th>Latitude</th>
                <th>Longitude</th>
            </tr>
            <?php
            $result = TiaDB::getInstance()->get_postcodes_by_person_id($personID);
            while($row = mysql_fetch_array($result)) {
                $postcode = $row["postcode"];
                $lat = $row["latitude"];
                $long = $row["longitude"];
                echo "<tr><td>" . strip_tags($postcode,'<br><p><h1>')."</td>";
                echo "<td>". strip_tags($lat)."</td>\n";
                echo "<td>". strip_tags($long)."</td></tr>\n";
            }
            ?>
        </table>

 

Maps page:

	Postcode: <input type="text" id="postcode" size="10" />
<input type="submit" value="Place Marker" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, placeMarkerAtPoint)" />
<input type="submit" value="Center Map" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, setCenterToPoint)" />
<input type="submit" value="Show Lat/Lng" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, showPointLatLng)" />

<div id="map">
</div>

 

Link to comment
https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/
Share on other sites

passing a session variable (any variable for that matter) into a text field:

 

<input type="text" name="foo" value="<?php echo (isset ($_SESSION['bar']) ? htmlentities ($_SESSION['bar']) : ''); ?>" />

 

Many thanks for that :) Now I'm trying to make the submit buttons to be pressed automatically, is that possible?

Unfortuantely the code I have is not a form:

 

    
    <script src="http://maps.google.com/maps?xxx" type="text/javascript"></script>
<script src="http://www.google.com/uds/api?xxx" type="text/javascript"></script>
<script src="includes/gmap.js" type="text/javascript"></script>
<body>
        <p>
        <input type="text" name="postcode" value="<?php echo (isset ($_SESSION['postcode']) ? htmlentities ($_SESSION['postcode']) : ''); ?>" />
<input type="submit" value="Place Marker" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, placeMarkerAtPoint)" />
<input type="submit" value="Center Map" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, setCenterToPoint)" />
<input type="submit" value="Show Lat/Lng" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, showPointLatLng)" />

<div id="map">
</div>

    </body>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.