GodAtum Posted December 3, 2009 Share Posted December 3, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/ Share on other sites More sharing options...
mrMarcus Posted December 3, 2009 Share Posted December 3, 2009 so, what seems to be the issue at hand? what's it currently (not) doing? Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970783 Share on other sites More sharing options...
GodAtum Posted December 3, 2009 Author Share Posted December 3, 2009 Its not populating the postcode field on the maps page with the postcode value on the address page. I'm thinking of maybe using a session variable to store the postocode in but how would I pass that into a text field? Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970807 Share on other sites More sharing options...
mrMarcus Posted December 3, 2009 Share Posted December 3, 2009 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']) : ''); ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970810 Share on other sites More sharing options...
GodAtum Posted December 3, 2009 Author Share Posted December 3, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970826 Share on other sites More sharing options...
mikesta707 Posted December 3, 2009 Share Posted December 3, 2009 Not with PHP, you can use Javascript to submit the form automatically, or you can just submit the variable to the processing page itself Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970830 Share on other sites More sharing options...
GodAtum Posted December 3, 2009 Author Share Posted December 3, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/183878-populating-a-textbox-from-a-hyperlink/#findComment-970843 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.