Forum Moderators: mack

Message Too Old, No Replies

Javascript question

Passing variables to PHP

         

sjthomas

11:11 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



Hi there, I'm still a bt new to javascript but I know a bit of PHP. What I'm trying to do is create a page with a drop down menu which, when a user selects an option displays some details in a table next to the menu. The way I was thinking about doing it would be to use a drop down box that reloads the page everytime passing a php variable through the url. Is there an easier way than this?

Many thanks

coopster

11:15 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, sjthomas!

I guess it's either that or preload all the possible data options and change the displayed table client-side via javascript. And this would only work if the user has javascript enabled in their browser.

The way you described is probably the best option. Except, I would use a POST rather than GET in the form.

sjthomas

8:36 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



Cheers for that. Just a quick question though, is there any particular reason why you would use POST instead of GET? Like I said I'm still a bit new to this and wasn't aware that there were great differences.

Cheers

coopster

10:47 pm on Sep 9, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Well, I may have spoken prematurely without knowing entirely what your application is doing. URIs, Addressability, and the use of HTTP GET and POST [w3.org] may be of interest to you.

sjthomas

11:09 pm on Sep 9, 2004 (gmt 0)

10+ Year Member



Cheers for that link and the warm welcome. I think I'm better off using GET in line with the W3C's URI adressability (is that even a word!?!?) statement as it selects a product that I guess potential customers may want to send links out to/bookmark. I've left the page as it is for now using the PHP GET process as opposed to doing anything client side. I think its probably the best option.

Cheers for your help!