View Full Version : Passing values from a list box to a text box
05-19-2004, 03:55 PM
I have put together a form in PHP and HTML that I want to update rather than re-write.
At present I have a text box called country that php checks to see that it is filled in (Not Empty). It then passes that value ($country) on to the rest of the routine and adds itself to the database. Everything works fine.
Now I want to change the form and be able to control the data that the user can enter by giving them a List Box to pick from and then pass the listbox value to the text box
Does anyone know a simple way to do this?
05-19-2004, 08:18 PM
I don't think I understand.. do you want to use PHP for this?
So you're going to have the list box on the same page as the text box? When the user selects an option from the list box, you want it to be automatically input into the textbox?
I hope that made sense! But regardles, confirm what you're wanting and we can point you in the right direction.
05-20-2004, 07:59 AM
Sorry if I've not been very clear. I'm trying to learn this stuff and am suffering from very "senior" moments.
I want to replace the text input box with a list box on the form but have the selected option returned as if the user had typed it into the input box (as if it was still there).
On the form at present is the input box <input type="text" name="country" size="30" value="<?php print $country ?> />.
I want to replace this with a list box showing England, Ireland, Scotland, Wales and have the user select one and have this value passed to the PHP section as $country.
I think it should be simple but I have totally lost the plot. If I can avoid it I want to stay away from things like Java as I having enough trouble with PHP without adding another language to the already overworked grey matter :eek:
05-20-2004, 10:50 PM
I'm not sure if I understand what you mean by replace...
So what happens to the textbox? Ok, so you've got the list box, you make a selection. Now what? You submit the form and it goes to a PHP page and now you use the value of the list box as $country? If so, this is all:
So as long as you mean that this new PHP page will be filling in the value of the textbox with $country, this should work for you.
Let me know how that works out for you.
05-21-2004, 08:05 AM
Got it sorted - Grey matter had turned to jelly. I'm taking the moron exam next week but will probably fail and have to stay an idiot
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.