Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dynamic Dropdown issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamic Dropdown issue

 Post Reply Post Reply Page  <12
Author
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post Posted: 18 July 2003 at 12:09pm

thank you very much for the help and your time.

The error is gone but I am not getting any values.

Forgive for Just a little bit more info.

There is a table called empType.

This table has 2 fields: typeID and type.

TypeID is either 1, 2, or 3.

Then the Type field comprises Three levels of employees:

The deputy for resolving departmental issues; the associated deputy.

This deputy resolves issues relating to his/her section.

This deputy has a typeID of 2.

So when a name is selected from the emp table (another table), any names under staffset of dropdown menu that matches typeID 2 is populated into this dropdown.

Also each staffset is associated with a particular org code (this is also in the emp table).

Org codes range from 5401 to 5414.

If for instance, I select org code 5401 from the org dropdown menu, I expect to see associated deputy called John Doe to be automatically be populated into the staffset dropdown menu.

Please don't be upset if I paste the code.

The intent is to show the logical flow of things.

This incorporates the changes you made to the code.

My hope is that you can show why staffset is not getting populated with values from org.

 

<%@ Language="VBScript"%>
<%
Set emailDB = Server.CreateObject("ADODB.Connection")
emailDB.Open "dsn=to_odbc"

sql = "SELECT theEmp.empID, theEmp.LName+', '+theEmp.FName as fullname FROM theEmp WHERE theEmp.TypeID = 3"
set Supervisorset = emailDB.execute(sql)

'Definte and open the recordset
sql = "SELECT theEmp.empID, theEmp.LName+', '+theEmp.FName as fullname FROM theEmp WHERE theEmp.TypeID = 2"
set staffset = emailDB.execute(sql)

sql = "SELECT theEmp.empID, theEmp.lname+','+theEmp.fname as fullname FROM theEmp WHERE theEmp.TypeID = 1"
set Deputyset = emailDB.execute(sql)

%>
<head>
<title>Untitled</title>
<script language="javascript">
function setOptions(optSelect) {
 var selbox = document.frmNew.staff;
 selbox.options.length = 0;
 if (optSelect == " ") {
  optSelect.options[optSelect.options.length] = new Option('Please select one of the options above first',' ');
 }
 if (optSelect == "ORG") {
 <%
 'lets queueu up the recordset, check if it has records, then output some options
 Do Until staffset.EOF
  'lets dynamically add to the javascript
  Response.Write "selbox.options[selbox.options.length] = new Option('" & staffset("empID") & "','" & staffset("fullName") & "');" & vbCrLf
  staffset.MoveNext
 Loop

 'Now reset the recordset so we can use further down
 staffset.MoveFirst
 %>
 }
}
</script>
</head>

<body>

    <tr>
      <td>Select Organization Code:</td>
      <td width="41%">
       <select name="ORG"  size="1" onchange="setOptions(document.frmNew.ORG.options[document.frmNew.ORG.selectedIndex].value);">
        <option value="5401">5401</option>
        <option value="5402">5402</option>
        <option value="5403">5403</option>
        <option value="5404">5404</option>
        <option value="5406">5406</option>
        <option value="5408">5408</option>
        <option value="5414">5414</option>
      </select>
    <%if errorcode3 = "yes" then%> <font color="#FF0000"><strong>*please insert the Organization Code</strong> </font> <%end if%> </td>
    </tr>
    <tr>
      <td>Name of the immediate supervisor?</td>
      <td> <select name="Supervisor">
      <OPTION value="-1" SELECTED>&lt;Choose One&gt;</OPTION>
          <%
while not Supervisorset.eof
%>
          <option value="<%=Supervisorset(0)%>"><%=Supervisorset(1)%></option>
          <%
 Supervisorset.Movenext
 wend
 Supervisorset.close
 set Supervisorset = nothing

%>
        </select></td>
    </tr>
    <tr>
 <td>Name of Affected Deputy Director?</td>
 <td>
  <select name="staff" >
  <%
  Do while not staffset.eof
  %>
  <option value="<%=staffset(0)%>"><%=staffset(1)%></option>
  <%
   staffset.MoveNext
  Loop
  'Now we're done, let's release all the objects
  staffset.close
  set staffset = nothing
  %>
  </select>
 </td>
  </tr>
    <tr>
      <td>Name of the Deputy Director? </td>
      <td> <select name="Deputy">
          <%
    while not Deputyset.eof
         %>
          <option value="<%=Deputyset(0)%>"><%=Deputyset(1)%></option>
          <%
 Deputyset.Movenext
 wend
 Deputyset.close
 set Deputyset = nothing

  %>
</select></td>
    </tr>
  </table>
</form>
</body>
<%

'free up resources.
emaildb.close
set emaildb = nothing
%>

Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.