Cooper94 Posted April 26, 2009 Share Posted April 26, 2009 mark1 = new GMarker(new GLatLng(openInfoWindowHtml("<?php echo $two ?>"), -75.240867), { icon: blueIcon}); I am trying to put and echo in a javascript code is this possible and if so is this the right way? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/ Share on other sites More sharing options...
nankoweap Posted April 26, 2009 Share Posted April 26, 2009 try: mark1 = new GMarker(new GLatLng(openInfoWindowHtml("<?= $two ?>"), -75.240867), { icon: blueIcon}); Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/#findComment-819790 Share on other sites More sharing options...
Mchl Posted April 26, 2009 Share Posted April 26, 2009 What exactly are you trying to achieve? And note: Java is not JavaScript is not Java Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/#findComment-819804 Share on other sites More sharing options...
.josh Posted April 26, 2009 Share Posted April 26, 2009 That code will echo the var and when it all gets sent to the browser, the js will execute with the hardcoded var output. I hope you are not thinking the js will execute server-side... Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/#findComment-819811 Share on other sites More sharing options...
mikesta707 Posted April 26, 2009 Share Posted April 26, 2009 making Javascript (not java) and PHP talk to each other is somewhat difficult to understand. Since PHP is parsed on the server side, and javascript on the client side, the only way for these two languages to really talk to each other (based on my understanding. I could be wrong) is through post/get variables. One thing you could do is make a hidden form, and set the value to some php value, and then use javascripts HTML DOM functions to get that value, IE <!-- javascript element=document.getElementById('hiddenfield').value; mark1 = new GMarker(new GLatLng(openInfoWindowHtml(element), -75.240867), { icon: blueIcon}); and then you would just make the hidden form as such <input type="hidden" value="<?php echo "myvalue"; ?>" /> I might have my syntax a little off, but the basic Idea is there. Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/#findComment-819815 Share on other sites More sharing options...
Mchl Posted April 26, 2009 Share Posted April 26, 2009 I suggest we refrain from giving all possible solutions, until Cooper94 tells us what he wants to do Quote Link to comment https://forums.phpfreaks.com/topic/155736-javaphp/#findComment-819819 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.