PHP vs JavaScript
Posted: Wed Apr 26, 2017 11:33 am
Hi, I have a website that's built with JavaScript, but I'm wanting to take PHP now and build it again using the server-side language. I've used PHP to build me an interface to add items and manage them in a SQL database, but now that that's done, I've got to turn to the actual website. I have to admit I'm not sure how to convert some of the functionality I get with JavaScript into PHP. I can build the basic HTML page with PHP, but when it comes to the script code, I don't know how I can get the same effect using PHP. I have a simple function to display my category menus, and I'll quote it here so if someone wants to take a look at it and make suggestions of how I can use PHP to get the same functionality, feel free to comment. Of course, JavaScript and PHP never the twain shall meet, but I wonder how I can use PHP in it's place. I may have to continue to use the JavaScript, I don't know. But feedback would be helpful. Here's my function:
Kevin
Thanks,function ToggleDiv(chk,sub){
var setMain=document.getElementById(chk);
var lastSet=document.getElementById(setPrev);
var setSub=document.getElementById(sub);
var lastSub=document.getElementById(subPrev);
if(sub=="blankDiv"){
lastSub.style.display="none";
}
lastSet.style.display="none";
setMain.style.display=setMain.style.display=="block"?"none":"block";
setPrev=chk;
setSub.style.display=setSub.style.display=="block"?"none":"block";
subPrev=sub;
}
Kevin