Re: Automatic Listboxes
| From: | Bogdan Stancescu | Date: | Wed, 16 Jan 2002 00:19:13 +0000 |
| Subject: | Re: Automatic Listboxes | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15861@lists.php.net to get a copy of this message | ||
You'll have to submit the data. Just that instead of pushing "go", you can get
JavaScript to do that. For instance,
<form name="myForm1" action="<? echo $PHP_SELF?>">
<select name="country" onChange="document.myForm1.submit()">
<option value="Albania">
<option value="Andorra">
</select>
</form>
<form name="myForm2" action="<? echo $PHP_SELF?>">
<select name="country" onChange="document.myForm2.submit()">
<option value="Albania">
<option value="Andorra">
</select>
</form>
<form name="FinalForm" action="final_URL">
<select name="country">
<option value="Albania">
<option value="Andorra">
</select>
<input type="submit">
</form>
You'll then have to check whether you have any field empty and, if so, echo the same form
again, with the empty element populated. The final form actually contains the button which gets to
the final page.
Alternatively you could use a single form, but then you'll have both pieces of code (echoing
the form and echoing the final page) in the same PHP - easily solvable with include() for clean
coding.
HTH
Bogdan
Chris Payne wrote:
> Hi there everyone,
>
> Hope you are all having a good new year :-)
>
> I have a problem, I am working on a search engine for a Travel Agents and before you get to the
> actual type-in search field, you have to select from 3 pulldowns.
>
> The first pulldown is country, then the second should popuplate from whichever country is
> selected and so on. My question is this:
>
> How can I populate a pulldown box in a form from a DB automatically? In other words, what I
> need is once they have selected the first listbox, instead of having to click GO to populate the
> second one it does it automatically after selecting the entry in the first box and so on.
>
> Can anyone help?
>
> Thank you all so much :-)
>
> Regards
>
> Chris Payne
> www.planetoxygene.com