Re: A list box that changes what HTML is displayed.



chadsspameateremail@xxxxxxxxx escribió:
I first should list my background and that is that I'm new to PHP.
I would like to be able to have an HTML form where there is a list
that you choose from. Depending on what item is chosen in the list
different HTML is displayed somewhere else on the page. I know this
might be possible by adding a submit button and reloading the page.
But is there a way to do it without the submit button?

Not with PHP. And the fact that you're even asking shows that you don't really understand how PHP works. PHP runs on the web server and once the output of the script is sent to the browser, PHP is done: it can't reach the client computer and change anything there.


I know that Java might be able to accomplish this where depending on
what is selected it changes what is displayed but what is possible
from PHP?

A Java applet? Trust me, you don't want to mess with that. But it'd be very simple with some JavaScript ;-)

I know the page may need to be reloaded with the new data.

That depends on how large and variable the data is:

- If you only want to, let's say, display different invoice options depending on the answer to "Personal / Enterprise", you can load everything and use JavaScript to change the "display" CSS attribute.

- If you want to display cities depending on the country, well, preloading all the cities in the world may result in a 10MB document, thus you need AJAX (the J in AJAX is for JavaScript).


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.