Page 1 of 1

Is this Possible with PHP alone?

Posted: Mon Aug 31, 2009 6:36 am
by nathanbrooks
Hi there,

Was wondering if the following is possible to do with PHP alone and nothing else.

Is it possible to have one drop-down menu with which you must select the nation you live in, and once you have selected a nation, without pressing anything, a drop-down menu pops up with a selection of provinces/states for you to select.

So in otherwords the second drop down menu only pops up once you click on a country on the previous drop down.

Hope I am making sense here.

Re: Is this Possible with PHP alone?

Posted: Mon Aug 31, 2009 7:21 am
by papa
Just use onclick submit on your dropdown.

If that var is set, show the next dropdown with appropriate data.

Re: Is this Possible with PHP alone?

Posted: Mon Aug 31, 2009 8:08 am
by Eran
I think he meant without page refresh so submitting would probably not be a good idea.

As to the OP original question - This can be achieved using client-side technologies only, namely Javascript.

Re: Is this Possible with PHP alone?

Posted: Tue Sep 01, 2009 1:03 am
by nathanbrooks
Thanks pytrin that is exactly what I was talking about.

I suppose that Ajax is way beyond me at the moment so I don't want to get into it unless it is absolutely necessary. How tricky would it be to do it with javascript?

Any links or suggestions as to where I can get some help on this?

Re: Is this Possible with PHP alone?

Posted: Tue Sep 01, 2009 2:39 am
by Eran
One approach is to have all the information available on the page, with some of it hidden. You can then show/hide information as the user changes his selection. Take a look at the following example - http://blog.movalog.com/a/javascript-toggle-visibility/
If you want to retrieve dynamic information from the server (for example, something that is stored in files or a database), you would have to use AJAX techniques.

You can try one of the available Javascript frameworks, such as jQuery ExtJs and others. They make those common operations very easy to implement (including ajax).