This is a discussion on A list box that changes what HTML is displayed. within the PHP Language forums, part of the PHP Programming Forums category; I first should list my background and that is that I'm new to PHP. I would like to be ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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? 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? I know the page may need to be reloaded with the new data. But can that be done without the submit button? Maybe there's even a way of avoiding reloading the page to change the HTML? Even if I have to reload the page can it be done without the submit button? Thanks for your help. :) Chad. |
|
|||
|
<chadsspameateremail@yahoo.com> wrote in message
news:9a743c25-6c2b-460f-85ee-c58ea6cff251@79g2000hsk.googlegroups.com... > 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? > > 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? I know the page may need to be reloaded with the new data. > But can that be done without the submit button? Maybe there's even a > way of avoiding reloading the page to change the HTML? Even if I have > to reload the page can it be done without the submit button? > > Thanks for your help. :) > Chad. Your questions seem to point toward AJAX. You can combine JavaScript and php to create dynamic content. Google AJAX. Vince |
|
|||
|
On 26 Jun, 09:52, chadsspameaterem...@yahoo.com wrote:
> 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? > > 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? *I know the page may need to be reloaded with the new data. > But can that be done without the submit button? *Maybe there's even a > way of avoiding reloading the page to change the HTML? *Even if I have > to reload the page can it be done without the submit button? > > Thanks for your help. :) > Chad. Rather than Java, I think you mean javascript. All the questions that you are asking are client side ones. The place to ask this is certainly in a javascript newsghroup. However, since there is already so much information out there about how to do this, I would urge you to search on Google first. |
|
|||
|
chadsspameateremail@yahoo.com wrote:
> 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? > Only with some javascript, and possibly something like Ajax as well. I.e. you cannot alter what is on a page without client side intelligence, or reloading some or all o the info, or both. > 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? I know the page may need to be reloaded with the new data. > But can that be done without the submit button? Yes, but only by using javascript to invoke a 'submit()' type function. > Maybe there's even a > way of avoiding reloading the page to change the HTML? Even if I have > to reload the page can it be done without the submit button? > The submit button is really he lest of your worries. As I said javascript of teh most minimal can get riond that. A lot depeds on how much informatin teh modified pages reprsent: if its not too much and its all text, redarwing with javascript alone using stuff 'made invisible' layerd ver and under visible stuff is not too hard. If however the possibilities are pretty large, then you want to reload some or all of the page dynamically: I believe ajax is the way to go here,but have no idea exactly how it works. Or just reload the WHOLE page. > Thanks for your help. :) > Chad. |
|
|||
|
chadsspameateremail@yahoo.com 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 -- |
|
|||
|
On Thu, 26 Jun 2008 01:52:09 -0700, <chadsspameateremail@yahoo.com> wrote:
> 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? You can simply have the list submit to a PHP script, where each option sends a different value. Depending on the value, you have the appropriate content display. To have the list submit when someone selects an option, see the onchange event handler for JavaScript. Also, search for the forms object. > 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? I know the page may need to be reloaded with the new data. > But can that be done without the submit button? Maybe there's even a > way of avoiding reloading the page to change the HTML? Even if I have > to reload the page can it be done without the submit button? You mean JavaScript, not Java. Making content avaialbe by means of JS alone is a bad idea, as many people may not have JS activated. Also, it doesn't even sound like you need Ajax, just the DOM objects in JS. You'll need to do quite a bit of researching on how to code JavaScript. > Thanks for your help. :) > Chad. -- Curtis, http://dyersweb.com |
|
|||
|
>>I know the page may need to be reloaded with the new data.
>> But can that be done without the submit button? > >Yes, but only by using javascript to invoke a 'submit()' type function. Well darn! I was figuring if a button can make "submit" behavior happen that maybe a list might be able to cause "submit" behavior to occur as well when a selection occurs. :-( |
|
|||
|
On Thu, 26 Jun 2008 13:31:27 -0700, <chadsspameateremail@yahoo.com> wrote:
>>> I know the page may need to be reloaded with the new data. >>> But can that be done without the submit button? >> >> Yes, but only by using javascript to invoke a 'submit()' type function. > > Well darn! I was figuring if a button can make "submit" behavior > happen that maybe a list might be able to cause "submit" behavior to > occur as well when a selection occurs. :-( > It can, google the onchange event handler for JavaScript. -- Curtis, http://dyersweb.com |
|
|||
|
<chadsspameateremail@yahoo.com> wrote in message
news:12aa5e35-495d-4c88-bd17-becaee5ac42d@34g2000hsf.googlegroups.com... > >>I know the page may need to be reloaded with the new data. > >> But can that be done without the submit button? > > > >Yes, but only by using javascript to invoke a 'submit()' type function. > > Well darn! I was figuring if a button can make "submit" behavior > happen that maybe a list might be able to cause "submit" behavior to > occur as well when a selection occurs. :-( > As Curtis has pointed out, you can, and it's not that hard to do at all. Google AJAX.... Vince |
|
|||
|
On Jun 27, 6:41*am, "Vince Morgan" <vinharAtHereoptusnet.com.au>
wrote: > <chadsspameaterem...@yahoo.com> wrote in message > > news:12aa5e35-495d-4c88-bd17-becaee5ac42d@34g2000hsf.googlegroups.com...>>>I know the page may need to be reloaded with the new data. > > >> But can that be done without the submit button? > > > >Yes, but only by using javascript to invoke a 'submit()' type function.. > > > Well darn! *I was figuring if a button can make "submit" behavior > > happen that maybe a list might be able to cause "submit" behavior to > > occur as well when a selection occurs. :-( > > As Curtis has pointed out, you can, and it's not that hard to do at all. > Google AJAX.... > Vince Try this link: http://satya61229.blogspot.com/2007/...t-list-by.html |