Jump to content
xisto Community
p_a

Php Menus Without Javascript Has PHP possibility to do it without JS

Recommended Posts

I have many PHP Books, PHP Bible among others, but no clear description how to build menus (dynamic) Javascript like. Is PHP enough strong to do this? I also have Javascript Bible, many possibilities are usable within PHP pages.Anybody has experience in creating dynamic menus in PHP?

Share this post


Link to post
Share on other sites

How do you mean dymanic? if you mean like the mouse over and display alternate options, then I really don't think so, that is a javascript, dhtml, css, or flash relm, something client side, the only way a mouse over menu would work with php is if by some action you could submit the page on mouseover and return new results, but taht wouldn't be efficeant.Besides the very name, PHP bible, probably wouldn't tell you how to do something with Javascript if it could be done with PHP.

Share this post


Link to post
Share on other sites

You cannot create any dynamic menus using PHP because it executes on the server, not at the client. JavaScript executes on the client-side, so much more dynamicity is available. A few people have figured out how to create multi-level "pop-out" menus using CSS, and if you want to find that, just google it!Sorry that you can't use PHP for your menus...

Share this post


Link to post
Share on other sites

You can use PHP to send the HTML/DHTML/JavaScript/whatever code to the client. The dynamic generation could be done with PHP to change the entries the menu contains, for example. The actual menu would be constructed using, most likely, a combination of HTML and JavaScript. I don't know why anyone would want to do this - menus are usually a static method of travelling around a web site.

 

Such as:

<?phpecho '<whatever>' . date('M jS') . '</whatever>';?>

Share this post


Link to post
Share on other sites

Javascript is, of course, very usable. I used even few Javascript menu generators. But, sometimes I would like to do something like this: I have a website with, for example 10 webpages. I want to have the same header and footer at all of them. I make pages, and include the header.php at the top, and the footer.php at the bottom. Javascript menu is in the header.php. Menu is simple, and complete inside one function. When I started website from initial index.something (may be .php or .html) I do not see the header at all (even it's included). The most interesting thing is the fact: I save the Javascript function to the .js file, I put the line of code where I am calling the .js from header.php, and - everything works! Why? Where is the problem? It has to work both ways by any logic! Because it's the same thing. Or it is not.

Share this post


Link to post
Share on other sites

Your server probably don't support PHP scripting, so none of your PHP scripts will work.PHP, ASP etc are server-side scripts, so the programs to run the scripts has to be installed on the server.Javascript is a browser-side scripting language, so it will work as long as the browser supports it.If, you get hosted here on Xisto, your PHP scripts will work.

Share this post


Link to post
Share on other sites

I can see the complete page with header and footer included. Problem is the menu in header. If the Javascript code function is inside the header.php it will not work, it will not be visible in the webpage. If it is outside header.php as, for example menu.js, I just put the ordinary code to call the Javascript from header.php, it works perfect.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.