Click to See Complete Forum and Search --> : [RESOLVED] PHP/ Javascript Dropdown box help


markfc
02-20-2008, 06:27 AM
Hi Everyone.

I need a little help with some code on a php form. I think it's more javascript related but not sure.

I have a drop down box called say 'products' and next to it is a text box called 'other name'

The dropdown list has product names, product 1, product 2, product 3, and Other.

If a user chooses a product from this list I want it to copy the Product Name into the text box and make it readonly.

If they choose Other from the dropdown menu then I want them to be able to type in a product name in the text field.

Sounds simple but I really don't know where to start apart from using an onclick() on the drop down!

Thanks for any pointer you could give me!

Mark

markfc
02-20-2008, 07:18 AM
Mmm, okay I'm nearly there now!!

http://www.theboyinwales.com/select.html

Just need the box readonly unless they choose 'other'

doesn't seem to quite work at the moment.

<form name="ex" method="POST"><div align="center">
<select name="sel" size="1"
onchange="document.ex.selvalue.value = document.ex.sel.options[document.ex.sel.selectedIndex].text; if (document.ex.sel.selectedIndex==67) {document.ex.selvalue.disabled=true;}else{document.ex.selvalue.disabled=false;}">
<option value="100">full</option>
<option value="5">slight</option>
<option value="50">half</option>
<option value="67">Other - Please Specify</option>
</select>
<input type="text" name="selvalue" size="20"
</div></form>