Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dropdown appears on selection from first dropdown

Status
Not open for further replies.

9h1lo

Technical User
Sep 28, 2009
9
MT
need some suggestions here

have a php script doing a search using post with various options in a dropdown and a query in a textbox

now I would like that when a specific option is selected (only 1) in the dropdown, the textbox changes into another dropdown with pre-defined options

how would this be possible ?
 
Have a function that runs on the onChange event of the dropdown, and checks the value that has been selected. If it matches the defined value, make the dropdown visible, and the text box invisible.

Code:
function show_dropdown(){
if(document.getElementById('dropdownid').value=='the specified value'){
document.getElementById('textboxid').style.display=none;
document.getElementById('newdropdownid').style.display="block";
}
else{
document.getElementById('textboxid').style.display=block;
document.getElementById('newdropdownid').style.display="none";
}
}

And your HTML
Code:
<input type=text id="textboxid">
<select id="newdropdownid" style="display:none">
...
</select>

}


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
thanks for the tip...is this javascript or php ?

 
Javascript, since PHP can't actually do it.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top