Link to home
Start Free TrialLog in
Avatar of Cutthroat_Trout

asked on

Form control using drop down menus.

I am creating a form to help with an inventory search but I want the form to disable one of the select fields (or force it to be set to all models). The form is simple and has one radio button option and then two select lists. What I need help with is making the second select list become disabled (and/or automatically making that list default to All Models)  if any make other than Honda is selected from the vehicle make select list. Code has been pasted below. Help would be greatly appreciated.

<form name="sort" action="search-vehicle-info.php" method="post" style="margin: 0;">
									  <table  border="0" cellspacing="2" cellpadding="2" class="form_copy" width="100%" >    
										  <tr valign="top">
										   <td align="left" nowrap="nowrap">
												<label for="Model"><strong>Vehicle Type</strong></label><br>												
                                               	<input type="radio" name="vehicle_type" value="All" checked> All
                                                <input type="radio" name="vehicle_type" value="New" > New
												<input type="radio" name="vehicle_type" value="Certified_Used" > Certified Used
												<input type="radio" name="vehicle_type" value="Used" > Used  
                                           <td align="left" nowrap="nowrap">
												<label for="Make"><strong>Vehicle Make</strong></label><br>												
											  <select tabindex="7" name="Test">
												<option value="All" >All Makes</option>
                                                <option value="Honda" >Honda</option>
                                                <option value="Non-Honda" >All Non-Honda Makes</option>
                                                <option value="Chevrolet" >Chevrolet</option>
                                                <option value="Ford" >Ford</option>
                                                <option value="GMC" >GMC</option>
                                                <option value="Hyundai" >Hyundai</option>
                                                <option value="Jeep" >Jeep</option>
                                                <option value="Lexus" >Lexus</option>
                                                <option value="Nissan" >Nissan</option>
                                                <option value="Saab" >Saab</option>
                                                <option value="Subaru" >Subaru</option>
                                                <option value="Toyota" >Toyota</option>
                                                <option value="Volkswagen" >Volkswagen</option>
											<td align="left" nowrap="nowrap">
												<label for="Model"><strong>Vehicle Model</strong></label><br>												
											  <select tabindex="7" name="vehicle_model">
                                              	<option value="All" >All Models</option>
												<option value="Accord" >Accord</option>
                                                <option value="Civic" >Civic</option>
                                                <option value="CRV" >CRV</option>
                                                <option value="Element" >All Non-Honda Makes</option>
                                                <option value="Fit" >Fit</option>
                                                <option value="Odyssey" >Odyssey</option>
                                                <option value="Pilot" >Pilot</option>
                                                <option value="Ridgeline" >Ridgeline</option>
                                                <option value="S2000" >S2000</option>
											<td align="center" valign="bottom">
										     <input name="submit" type="submit" id="submit" value="Sort Inventory" >

Open in new window

Avatar of furtive
Flag of Canada image

Put this in a function called by the onchange event of document.sort.Test :

var brand = document.sort.Test;
var model = document.sort.vehicle_model;
if (brand.options[brand.selectedIndex].value != "Honda") {
  model.disabled = true;
else {
  model.disabled = false;

Open in new window

Avatar of Cutthroat_Trout


I am going to need a little more help than that.

I can you please show me with that code implemented?

Avatar of furtive
Flag of Canada image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That works. Thanks!