Eoin Posted May 15, 2012 Share Posted May 15, 2012 i am having a problem passing variables from a php file to a html file using a javascript funtion. here is the code i have. /////////InteractiveMap.HTML//////////////////////////////////////////////////// <script type="text/javascript"> // This function is called when a building is clicked. function buildingClick(id,name,desc) { var mywin; var isOpen = false; var searchInt; var passVal; passVal = desc; mywin = window.location.href = "informationPage.html"; searchInt = setInterval(function(){if(isOpen){var display=mywin.document.getElementById("infoArea"); display.value = passVal;}});} /////////////////////////////////////////////////////////////////// ////////////InformationPage.html/////////////////////////////// <script type="text/javascript"> window.onload = function(){window.opener.window["isOpen"] = true;}; </script> <textarea disabled id="infoArea"></textarea> ////////////////////////////////////////////////////// I am just tryin to display the variable desc in the textarea "infoArea" but it wont work.Any help would be appreciated. eoin Quote Link to comment https://forums.phpfreaks.com/topic/262564-project-deadline-in-1-dayplease-help/ Share on other sites More sharing options...
scootstah Posted May 15, 2012 Share Posted May 15, 2012 <textarea disabled id="infoArea"><?php echo $desc; ?></textarea> Like that? Quote Link to comment https://forums.phpfreaks.com/topic/262564-project-deadline-in-1-dayplease-help/#findComment-1345614 Share on other sites More sharing options...
Eoin Posted May 15, 2012 Author Share Posted May 15, 2012 Unfortunately not.the variable $desc is a variable from a different page which is being passed when the buildingClick() function is called. Quote Link to comment https://forums.phpfreaks.com/topic/262564-project-deadline-in-1-dayplease-help/#findComment-1345617 Share on other sites More sharing options...
Jessica Posted May 15, 2012 Share Posted May 15, 2012 In the URL? use $_GET['desc']; Quote Link to comment https://forums.phpfreaks.com/topic/262564-project-deadline-in-1-dayplease-help/#findComment-1345676 Share on other sites More sharing options...
ignace Posted May 15, 2012 Share Posted May 15, 2012 mywin = window.location.href = "informationPage.html"; searchInt = setInterval(function(){if(isOpen){var display= mywin.document.getElementById("infoArea"); display.value = passVal;}});} ROFLMFAO ... you just started writing JS or something? *Creative* solution Do as jesirose said: window.location.href = "informationPage.html?desc=" + desc; And what scootsah said: <textarea disabled id="infoArea"><?php echo htmlentities(strip_tags($_GET['desc'])); ?></textarea> But it's quite possible the .html has to be .php otherwise the PHP will not get parsed (until you tell it to parse .html as well of course). Quote Link to comment https://forums.phpfreaks.com/topic/262564-project-deadline-in-1-dayplease-help/#findComment-1345709 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.