adredz Posted December 2, 2009 Share Posted December 2, 2009 I have 4 divisions, the three being the the buttons and the fourth is the display which only shows up when one of the buttons is clicked. My idea is to assign the id of the fourth div when the var tabNum is equal to 3. Could you pls check the php part of my code because it creates error. Here's my code below: <html> <body> <script type="text/javascript"> var tabNum=0; function setTab(tab) { tabNum = tab; } function getTab(tab){ return tabNum; } </script> <div id="portfolio"> <div id="web" onclick="setTab(1)">1st tab</div> <div id="logo" onclick="setTab(2)">2nd tab</div> <div id="flyer" onclick="setTab(3)">3rd tab</div> <div id="<?php if ((echo "<script language='javascript'> getTab(); </script>"; ) == 3) { echo "web_entries;" } ?>"></div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/183716-how-to-to-call-an-return-javascrtip-function-from-php/ Share on other sites More sharing options...
Kieran Menor Posted December 2, 2009 Share Posted December 2, 2009 Your code makes no sense, as PHP is executed server-side, which is before any javascript is executed. May I suggest using AJAX to get the desired effect? Link to comment https://forums.phpfreaks.com/topic/183716-how-to-to-call-an-return-javascrtip-function-from-php/#findComment-969643 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.