HTML Drop down list assistance

Permabanned
Joined
25 Oct 2004
Posts
9,078
Hi All,

Im currently trying to figure out how i can implement a feature on a site ive been working on and I just cant figure it out, ive only been doing html/css and recently started on php but still a long way to go before i know what on earth im doing.

Basically I have a drop down list of multiple charity names which each contain a value which corresponds to there email address.

The thing im trying to do is get that value used to display in a text box which is then later used by the server for donations.

As it stands currently the list is working fine, but I cant figure out how to pull the value from the drop down list and have it displayed in a text box.

Any assistance would be greately appreciated.
 
You will need to use javascript to set a text box value.

Add the following code to the drop down declaration.
Code:
onchange='document.getElementID('textboxid').value=this.options[this.selectedIndex].value';

Replace textboxid with the id of the text box you want to assign the value to. It's untested but should work :o
 
Is it possible to use the value contained within a text box to search the drop down list and have the correct option selected ?

ie in my case, the value in the text box is the email address of the charity, but we dont want users to see the email address, so instead we have a list of the charity names.

My option list basically contains a list of charities with the value of each set to the email address, what i would like to happen is that when a user selects the charity name the email address is shown in a text box (thats invisible) so that our donation system can work.

Now when the user returns the page the email address is still shown but the charity name has gone and the list has defaulted to option 1.

Is it possible to use the value contained in the textbox to have the correct drop down menu item selected also.
 
Back
Top Bottom