By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,704 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,704 IT Pros & Developers. It's quick & easy.

Drop-Down/Text Box Combination?

P: n/a
I am a javascript newbie and did not see anything quite like this in
sections 1-5 of the FAQ or on a Google search.

Is there a generic javascript example of a compound drop-down/text box,
i.e., if the user selects an item from the drop-down, the selected item
populates the text box, but the user can also type their own ad-hoc
value into the text box if desired?

I would like to include such a control in a php/mysql web form I am
developing.

Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
@SM
bonehead a ecrit :
I am a javascript newbie and did not see anything quite like this in
sections 1-5 of the FAQ or on a Google search.

Is there a generic javascript example of a compound drop-down/text box,
i.e., if the user selects an item from the drop-down, the selected item
populates the text box, but the user can also type their own ad-hoc
value into the text box if desired?
<form>
<input type=text name="truc">
<select onchange= if(this.options.selectedIndex==0)
alert('Do an other choice');
else
this.form.truc.value=this.options[this.options.selectedIndex].value;">
<option selected>Choisir une ville - Select a Town
<option value="Paris">Paris
<option value="London">Londres - London
<option value="Tokio">Tokio
</select>
</form>
I would like to include such a control in a php/mysql web form I am
developing.


???? pas ni compris - Not do unterstand - Yo no comprender
You make choice by menu
Then you can change the value of text
The php will receive the value of "truc" ( $truc )

Jul 20 '05 #2

P: n/a
Thanks
@SM wrote:
bonehead a ecrit :

I am a javascript newbie and did not see anything quite like this in
sections 1-5 of the FAQ or on a Google search.

Is there a generic javascript example of a compound drop-down/text box,
i.e., if the user selects an item from the drop-down, the selected item
populates the text box, but the user can also type their own ad-hoc
value into the text box if desired?

<form>
<input type=text name="truc">
<select onchange= if(this.options.selectedIndex==0)
alert('Do an other choice');
else
this.form.truc.value=this.options[this.options.selectedIndex].value;">
<option selected>Choisir une ville - Select a Town
<option value="Paris">Paris
<option value="London">Londres - London
<option value="Tokio">Tokio
</select>
</form>
I would like to include such a control in a php/mysql web form I am
developing.

???? pas ni compris - Not do unterstand - Yo no comprender
You make choice by menu
Then you can change the value of text
The php will receive the value of "truc" ( $truc )


Jul 20 '05 #3

P: n/a
The simple answer is there is no combo box control in HTML. There is a
SELECT element, but this lacks the text box part of the combo box. Recently
I went looking for a combo box control myself. I found two, the first is
at

http://webfx.eae.net/dhtml/combobox/combobox.htm

It seems to be really slick but it did not layout well with respect to the
rest of my form (which was laid out in a simple table).

I also found a commercial control at:

http://www.ycode.com/

which ooks to be good, but I am not interested in buying a combo box.

In the end I just hacked up a control by implementing a button -
input(text) - button combination of un-named items in a form (with a named
hidden input) holding my final value. I used an (IE specific) IFRAME
containing a table to represent the drop down menu, that could be hidden
using CSS display/visibility. I create the menu dynamically using script
(in much the same way that the webfx control does).

I strongly suggest you look at the we control as it work very well is is
very well coded.

Hope this helps.

d.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.