clausowitz Posted July 16, 2011 Share Posted July 16, 2011 I have a script that will display a google map on my form. The lat and lon for the google map are stored in a hidden textbox. I use a javascript to retrieve the value of the textbox: <script type="text/javascript">document.getElementById('MyTextBox').value</script> Now I want to use this value, which is something like `30.123456, 29.123456` in the string: <div align="right" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div> <iframe width="550" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/api/staticmap?center='<?php echo ("javascript:document.getElementById('MyTextBox').value"); ?>'&zoom=12&markers=color:red|label:B|'<?php echo ("javascript:document.getElementById('MyTextBox').value"); ?>'&size=550x300&sensor=false">">'</iframe> <div align="left" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div> </div> This code doesn´t return the values, what is wrong? Marco Link to comment https://forums.phpfreaks.com/topic/242150-need-javascript-in-html-string/ Share on other sites More sharing options...
gizmola Posted July 16, 2011 Share Posted July 16, 2011 PHP is serverside, javascript is clientside. Serverside code runs on the server, and returns html to the client using http. Javascript code runs entirely on the client (workstation). Link to comment https://forums.phpfreaks.com/topic/242150-need-javascript-in-html-string/#findComment-1243597 Share on other sites More sharing options...
clausowitz Posted July 17, 2011 Author Share Posted July 17, 2011 That I already knew but it doesn´t explain how to solve this thing. Link to comment https://forums.phpfreaks.com/topic/242150-need-javascript-in-html-string/#findComment-1243757 Share on other sites More sharing options...
clausowitz Posted July 17, 2011 Author Share Posted July 17, 2011 I created a javascript session variable± function change(x) { sessvars.grid = document.getElementById(x).alt; } Now I want to pass the variable to the url but it doesn´t work± <div align="right" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div> <iframe width="550" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/api/staticmap?center='+sessvars.grid&zoom=12&markers=color:red|label:B|'+sessvars.grid&size=550x300&sensor=false">"></iframe> <div align="left" style="padding:4px; background-color:#D2F0D3;"><a href="#" onclick="return false" onmousedown="javascript:toggleViewMap('google_map');">close map</a></div> </div> Any thought= Link to comment https://forums.phpfreaks.com/topic/242150-need-javascript-in-html-string/#findComment-1243806 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.