tmk4php Posted October 22, 2008 Share Posted October 22, 2008 Hi, I'm trying to pass a PHP variable holding a session ID to Javascript. I've gotten it to work successfully in every browser except Internet Explorer (I've only tested in IE7 and IE8beta, nothing earlier) by passing it through a hidden input field. Here is the code: <input type="hidden" id="dataxml" value="<?php echo $xmlsheet; ?>"> </form> <script type="text/javascript"> //other code myChart.setDataURL("temp/Data_" + dataxml.value); </script> $xmlsheet is holding the session ID. IE gives me an error saying that my 'dataxml' is undefined. Does anyone know why IE is throwing this error, or any way around it? Right now I'm just telling users not to use IE... Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/ Share on other sites More sharing options...
CroNiX Posted October 22, 2008 Share Posted October 22, 2008 what happens if you change myChart.setDataURL("temp/Data_" + dataxml.value); to myChart.setDataURL("temp/Data_" + document.getElementById('dataxml').value); or possibly myChart.setDataURL("temp/Data_<?php echo $xmlsheet; ?>"); Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672099 Share on other sites More sharing options...
alexweber15 Posted October 22, 2008 Share Posted October 22, 2008 CroNiX probably nailed it! (i woulda said the same thing but im cool because i use jQuery so it would be $('#dataxml').val(); ) Although i'm baffled as to how it works in all other browsers...???? ??? Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672126 Share on other sites More sharing options...
CroNiX Posted October 22, 2008 Share Posted October 22, 2008 bleh...jquery...use mootools A lot smaller, more functions, and better smoother animation. Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672132 Share on other sites More sharing options...
tmk4php Posted October 22, 2008 Author Share Posted October 22, 2008 CroNiX - you definitely nailed it! getElementById was the answer, and it now works in all browsers. Many thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672136 Share on other sites More sharing options...
CroNiX Posted October 22, 2008 Share Posted October 22, 2008 Sure, actually Im surprised it worked in the other browsers the way you had it. Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672138 Share on other sites More sharing options...
alexweber15 Posted October 22, 2008 Share Posted October 22, 2008 Sure, actually Im surprised it worked in the other browsers the way you had it. ditto. (i know i already said it). but still... wow! (no offence to OP) but i just didn't realize this was even possible!!! :o Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672260 Share on other sites More sharing options...
CroNiX Posted October 22, 2008 Share Posted October 22, 2008 My how browsers are making it easy to make mistakes by not being strict enough...I can't believe that IE of all things was the app that caught it. Quote Link to comment https://forums.phpfreaks.com/topic/129627-php-session-id-to-javascript-in-internet-explorer/#findComment-672270 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.