Link to home
Create AccountLog in
Avatar of freezilla

asked on

Classic ASP Conditional Drop Down

Ok, I've asked this question before but never have received an answer.  Here's what I have and it works on the front end, but won't submit the conditional part.  

It will insert a number (MCID) for the type of physician, but it totally ignores the actual physician name.

I don't think I'm that far off here, but am at my wits end trying to get this thing to function.

I've posted my code and can post the DB information if need be.

Any help is, of course, appreciated.
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>

<script type="text/javascript">

$(document).ready(function() {

		$.get("ChildCats.asp", {
			parent_id: $('#search_category_id option:selected').val()
		}, function(response){
//alert(response); // we alert the response first for testing purpose
			setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')", 400);
		return false;


function finishAjax(id, response){

function alert_id()
	if($('#sub_category_id').val() == '')
	alert('Please select a sub category.');
	return false;
.both h4{ font-family:Arial, Helvetica, sans-serif; margin:0px; font-size:14px;}
#search_category_id{ padding:3px; width:200px;}
#sub_category_id{ padding:3px; width:200px;}
.both{ float:left; margin:0 15px 0 0; padding:0px;}

<form action="calllog_submit.asp" method="post" name="form1">
<table width="800"  border="0" cellspacing="4" cellpadding="4">
    <td><strong>Patient Information</strong></td>
    <td>Today's Date:</td>
    <td><input type="text" name="datetime" value="<%=date()%>"></td>
    <td>Person Entering Referral: </td>
    <td><select name="entrant">
	<option value="">--Select Marketing Member--</option>
	<option value="MB">Mark Briggler</option>
    <td>Patient Name: </td>
    <td><input type="text" name="p_name"></td>
    <td>Patient Address: </td>
    <td><input type="text" name="p_address"></td>
    <td>Patient City: </td>
    <td><select name="p_city">
	<option value="">--Select City--</option>
      <option value="Aberdeen ">Aberdeen </option>
      <option value="Annapolis ">Annapolis </option>
      <option value="Arnold">Arnold</option>
      <option value="Arundel">Arundel</option>
      <option value="Baltimore ">Baltimore </option>
      <option value="Bel Air">Bel Air</option>
      <option value="Bethesda ">Bethesda </option>
      <option value="Bowie ">Bowie </option>
      <option value="Brooklyn Park">Brooklyn Park</option>
      <option value="Catonsville">Catonsville</option>
      <option value="Clarksville">Clarksville</option>
      <option value="College Park ">College Park </option>
      <option value="Columbia ">Columbia </option>
      <option value="Cumberland ">Cumberland </option>
      <option value="Elkridge">Elkridge</option>
      <option value="Ellicott City ">Ellicott City </option>
      <option value="Frederick ">Frederick </option>
      <option value="Fulton">Fulton</option>
      <option value="Gaithersburg ">Gaithersburg </option>
      <option value="Gambrills">Gambrills</option>
      <option value="Germantown ">Germantown </option>
      <option value="Glen Burnie">Glen Burnie</option>
      <option value="Hagerstown ">Hagerstown </option>
      <option value="Hanover">Hanover</option>
      <option value="Havre de Grace">Havre de Grace</option>
      <option value="Laurel ">Laurel </option>
      <option value="Linthicum">Linthicum</option>
      <option value="Lutherville">Lutherville</option>
      <option value="Maryland">Maryland</option>
      <option value="Millersville">Millersville</option>
      <option value="Ocean City ">Ocean City </option>
      <option value="Odenton">Odenton</option>
      <option value="Owings Mills">Owings Mills</option>
      <option value="Pasadena">Pasadena</option>
      <option value="Randallstown">Randallstown</option>
      <option value="Riverdale">Riverdale</option>
      <option value="Rockville ">Rockville </option>
      <option value="Salisbury ">Salisbury </option>
      <option value="Severn">Severn</option>
      <option value="Severna Park">Severna Park</option>
      <option value="Silver Spring ">Silver Spring </option>
      <option value="Towson ">Towson </option>
      <option value="Waldorf ">Waldorf </option>
      <option value="Washington, D.C.">Washington, D.C.</option>
      <option value="Westminster">Westminster</option>
	  <option value="White Marsh">White Marsh</option>
    <td>Patient State: </td>
    <td><select name="p_state">
<option value="Alabama">Alabama</option>
<option value="Alaska">Alaska</option>
<option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option>
<option value="California">California</option>
<option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option>
<option value="Delaware">Delaware</option>
<option value="Florida">Florida</option>
<option value="Georgia">Georgia</option>
<option value="Hawaii">Hawaii</option>
<option value="Idaho">Idaho</option>
<option value="Illinois">Illinois</option>
<option value="Indiana">Indiana</option>
<option value="Iowa">Iowa</option>
<option value="Kansas">Kansas</option>
<option value="Kentucky">Kentucky</option>
<option value="Louisiana">Louisiana</option>
<option value="Maine">Maine</option>
<option value="Maryland" selected>Maryland</option>
<option value="Massachusetts">Massachusetts</option>
<option value="Michigan">Michigan</option>
<option value="Minnesota">Minnesota</option>
<option value="Mississippi">Mississippi</option>
<option value="Missouri">Missouri</option>
<option value="Montana">Montana</option>
<option value="Nebraska">Nebraska</option>
<option value="Nevada">Nevada</option>
<option value="New Hampshire">New Hampshire</option>
<option value="New Jersey">New Jersey</option>
<option value="New Mexico">New Mexico</option>
<option value="New York">New York</option>
<option value="North Carolina">North Carolina</option>
<option value="North Dakota">North Dakota</option>
<option value="Ohio">Ohio</option>
<option value="Oklahoma">Oklahoma</option>
<option value="Oregon">Oregon</option>
<option value="Pennsylvania">Pennsylvania</option>
<option value="Rhode Island">Rhode Island</option>
<option value="South Carolina">South Carolina</option>
<option value="South Dakota">South Dakota</option>
<option value="Tennessee">Tennessee</option>
<option value="Texas">Texas</option>
<option value="Utah">Utah</option>
<option value="Vermont">Vermont</option>
<option value="Virginia">Virginia</option>
<option value="Washington">Washington</option>
<option value="West Virginia">West Virginia</option>
<option value="Wisconsin">Wisconsin</option>
<option value="Wyoming">Wyoming</option>
    <td>Patient Zip: </td>
    <td><input name="p_zip" type="text" size="5" maxlength="5"></td>
    <td>Patient Phone:</td>
    <td><input name="p_phone" type="text" size="15" maxlength="13"></td>
    <td><strong>Physician Information</strong></td>
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("cffdb.mdb") & ";"
Set GetCats = CreateObject("ADODB.Command")
GetCats.Prepared = true
GetCats.commandtext="SELECT MCID, MCName, MCDesc FROM MainCat"
set rsGetCats = GetCats.execute
    <td>Physician Specialty:</td>
	<div class="both">
		<h4>Select Specialty</h4>
		<select name="dr_name"  id="search_category_id">
		<option value="" selected="selected"></option>
        <%while not rsGetCats.eof
		MCID = rsGetCats("MCID")
		MCName = rsGetCats("MCName")%>
        <option value="<%=MCID%>"><%=MCName%></option>
	<div class="both">
		<h4 id="show_heading">Select Physician</h4>
		<div id="show_sub_categories" align="center">
			<img src="loader.gif" style="margin-top:8px; float:left" id="loader" alt="" />
    <td valign="top">Physician(s) Name(s): </td>
	<em>*Hold down the CTRL key to select multiple physicians</em></td>
    <td><textarea name="notes" cols="40" rows="10"></textarea></td>
    <td colspan="2"><input type="submit" value="submit"></td>

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

You need to "Request Attention" and get the javscript and jquery zones added to your question.
Avatar of sammySeltzer
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of freezilla


Here's the design of my databases.

ccfdb.mdb - This houses the physicians and it has two tables: MainCat and SubCat

MCID = The ID/Primary Key      
MCName = The speciality (OBGYN, Cardiology, etc.)
MCDesc = The description (not used)
SCID = The ID/Primary Key
MCID = The ID that's assigned to the different specialties (OBGYN is 1, Cardiology is 2, etc.)
SCDesc = The name of the actual physician - this is what I need inserted in from the second drop down menu.

physicians.mdb - This is what holds the form submissions

ID = ID/Primary Key
datetime - date and time when the form was submitted
entrant - person who entered the information
and so forth

This is enterting a "1" or "2" in the field "dr_name" and so forth that's coming from the MCID field.  What I want it to enter is the SCDesc from the other DB.  This is where I'm lost.
Ok, please make me understand where you think the issue is.

You select :

            <h4>Select Specialty</h4>

Then you expect one or more physicians, not their IDs but their names to populate here:

      <div class="both">
            <h4 id="show_heading">Select Physician</h4>
            <div id="show_sub_categories" align="center">
                  <img src="loader.gif" style="margin-top:8px; float:left" id="loader" alt="" />

Meanwhile, this query is all that you are trying to use to accomplish your objective here:
GetCats.commandtext="SELECT MCID, MCName, MCDesc FROM MainCat"

Am I on track so far?
You hit on what I needed to do and I figured it out from here.  Thank you.
You're very welcome.

great job!