Jump to content


Photo

How to integrate PHP and Javscript


  • Please log in to reply
7 replies to this topic

#1 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 28 August 2006 - 09:03 PM

I want to add some javascript rollover menus to my php pages. But the javascript menu items will be pulled from my MySQL databse.

I usually have a seperate .js file which I link in at the top of my HTML...

but if this seperate document is a php doc (that outputs javascript) will this still work..

what's the best way to go about this????

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 28 August 2006 - 09:22 PM

Instead of using Javascript for the rollover menus, think about using CSS. Most of the CSS implementations are based on simple <ul></ul> lists.  Take a look at http://css.maxdesign....au/listamatic/ for more information.

Ken

#3 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 28 August 2006 - 09:30 PM

The menus are supposed to pop up when a link is hovered on, not just change color....

can this be done with CSS???
sorry for not being clear...

#4 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 28 August 2006 - 09:57 PM

It is possable.
http://cssplay.co.uk/menus/index.html
Many examples of neat CSS menus. (including ones similar to that which you describe.)
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#5 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 28 August 2006 - 10:02 PM

Try this one:

http://www.dhtmlgood...mlgoodies_menu2

It uses an unordered list, but it also uses js to make it compatible with IE without using some crazy hacks the only work half the time.

#6 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 28 August 2006 - 11:07 PM

I like the last menu...thanks..1 question....

This may sound stupid..but I don't want to jarble up my <head> with all that css and script data..

can I make one big php file to echo the whole thing and just plop it into my header...and just include the php file....

JW

#7 Joe Haley

Joe Haley
  • Members
  • PipPipPip
  • Advanced Member
  • 103 posts
  • LocationCanada, eh?

Posted 28 August 2006 - 11:13 PM

I would use an external CSS stylesheet, and external script. thus only 2 lines need to be in the header, and the browser may cache the data for faster loading times.
Give a man a fish; you have fed him for today.  Teach a man to fish; and you have fed him for a lifetime
Don't teach men to program. Teach them to fish.

Please, try the RTFM solution before asking for help:
http://php.net/manual/en/index.php

#8 jwwceo

jwwceo
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 28 August 2006 - 11:40 PM

I already have a Style sheet applied...will this style sheet overide the other one for containers of the same type....

how do you make sure that for items like <html> or <p> the right style sheet is being used...






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users