PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri May 26, 2017 2:21 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PHP vs JavaScript
PostPosted: Wed Apr 26, 2017 11:33 am 
Offline
Forum Newbie

Joined: Wed Apr 26, 2017 9:40 am
Posts: 2
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:
Quote:
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;
}


Thanks,
Kevin


Top
 Profile  
 
 Post subject: Re: PHP vs JavaScript
PostPosted: Thu Apr 27, 2017 5:31 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6243
Location: Montreal, Canada
This looks like the sort of thing you'd want to keep client side. It would be possible server side, but you'd need to submit some kind of request to the server and trigger a page reload to render everything anew. Doesn't really make a ton of sense. Right tool for the job and all...

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
 Post subject: Re: PHP vs JavaScript
PostPosted: Sat Apr 29, 2017 11:02 am 
Offline
Forum Newbie

Joined: Wed Apr 26, 2017 9:40 am
Posts: 2
Yeah, I'm a little in doubt about what should remain client-side, and what should be php.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group