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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic form

Status
Not open for further replies.

joshnelson

Technical User
Jan 15, 2008
3
US
Hello...I'm trying to create a form that will offer different options based on what a user selects from a dropdown...

choosing "web" will offer one set of options in a form....while choosing "ebay" would offer the user another set of options in a form.

I'm not a programmer by any means but tinker with html/php and I dont think i can do this with either one of those.....and best i can tell i should probably use javascript to complete this task. Any thoughts or pointers on how to approach this or any tutorials on doing what i'm looking to do would be appreciated.

Thanks,

Josh
 
Are the drop downs static or dynamically filled?

If they are static, I would recommend for a "quick and easy" solution is to create all the selects on top of one another, and use:

Code:
 style="display:none"

on each one. Then when a user selects an option, hide all the drop downs instead of yours. In here, I would give each the same name, but different id's.

Code:
function hideAllButMe(strSelectId) {
    var dropdownArray = document.getElementsByName("dropdowns");
    var dropdown;
    for(var i = 0; i < dropdownArray.length; i++) {
        dropdown = dropdownArray[i];

        if(dropdown.id != strSelectId) {
            dropdown.style.display = "none";
        }else{
            dropdown.style.display = "";
        }
    }
}

Now with the above, you add the id of what you want to show through the onclick attribute.

Code:
<input type="button" value="web" onclick='hideAllButMe("webDropDown");' />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top