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

Updating drop down menu when previous menu is updated

Status
Not open for further replies.

ATCrunway1

Programmer
Apr 20, 2005
1
US
Hey there everyone...

This is probably an easy one for most; however, I'm a new IT programmer that is trying to learn most programming on-the-fly!!! Go figure... ANYWAY... So, please be descriptive for fear of not knowing what you're talking about.

I'm trying to figure out how to make a dropdown menu populate with a portion of a database listing that is selected by a previous drop down menu. CONFUSED??? So am I...

Example... A company may have many organizations within itself and each organization has several offices.... When you select the organization from the organization dropdown menu, the office dropdown menu only populates with the offices that belong to the selected organization. Database tables are set up where the organization has a numerical ID and the offices have an ID that corresponds to the Organizational ID.

HELP!!!!!

ATCrunway1
 
This is how I do it, using Javascript to refresh the window and call certain data from the database to populate a second drop-down menu based upon the first drop-down menu choice. I hope it makes sense.

JAVASCRIPT
Code:
function refreshwindow1(){  
   
     var form = document.forms[0]; 
     var pageurl = "<%=Request.ServerVariables("URL")%>";
     var servername = "<%=Request.ServerVariables("SERVER_NAME")%>";
     var sitepath = "<%=Request.ServerVariables("PATH_INFO")%>";
     var query = "<%=Request.ServerVariables("QUERY_STRING")%>";
	 var zcouncilTemp = "<%=request.QueryString("zcouncil")%>";	 
	 
	 	    for (var i = 0; i < form.zcouncil.length; i++){
				if (form.zcouncil.options[i].selected){
				var zcouncilTemp = form.zcouncil.options[i].value;
				}
			}
	
     form.action = "new.asp";
     
	 
     form.submit();
	 
}
HTML/VBScript
Code:
					<%if request("zcouncil") <> "" then
					zcouncil = int(request("zcouncil"))
					end if %>
                <select name="zcouncil" style="font-family: Arial; font-size: 8pt" onChange="refreshwindow1()">
                  <option value="">Choose One</option>
				  <% if zcouncil = "2" then %>
                  <option value="2" selected>Engineering</option>
				  <% else %>
				  <option value="2">Engineering</option>
				  <% end if %>
				  <% if zcouncil = "4" then %>
                  <option value="4" selected>Manufacturing</option>
				  <% else %>
				  <option value="4">Manufacturing</option>
				  <% end if %>
				  <% if zcouncil = "19" then %>
                  <option value="19" selected>Quality</option>
				  <% else %>
				  <option value="19">Quality</option>
				  <% end if %>				  			  				  
                </select>&nbsp;<font color="#FF0000">Council and Process Owner MUST be chosen prior to filling out form.</font></font></td>
				</tr>
				<% if zcouncil = "2" then %>
				<tr>
					<td width="100%" colspan="2">
						<font face="Arial" size="1">
						Process Owner<br>
						<select name="zprocess_identifier" size="1" style="font-family: Arial; font-size: 8pt">
							<option value="">Choose One</option>
							<%mysql2 = "SELECT ID, title from tbl_process_owner WHERE (Process_Owner1 IS NOT NULL) AND (Macro = '2' OR macro = '10')  order by title"%>
							<!--#INCLUDE FILE="../../../includes/sql-data2.INC" -->
							<%RS2.Open cmdTemp, , 1, 3%>
							<%WHILE NOT RS2.EOF%>
							<option value="<%=RS2("ID")%>"><%=RS2("title")%>-(<%=RS2("ID")%>)</option>
							<%RS2.MoveNext
							WEND
							RS2.Close
							SET RS2 = NOTHING
							ISData2.Close
							SET ISData2 = NOTHING %>
						</select></font></td>
				</tr>
				<% end if %>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top