473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Link two dropdowns so the second dropdown can use sql query

Hello good people,

Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet reservation of available resources (laptops, beamers, etc). The MySql database queries are already in place, as is the ASP administration panel. The frontend that users will see however, still needs some work. I'm really close, but since I'm no html/javascript guru I must confess that I sometimes might use workarounds in the code that would seem ambiguous or silly to experts.

Having said that, I would like to request some help for the following two points:
1. How can I make the first of two dropdowns trigger an onchange event so that the query that populates the second dropdown will be executed only onchange. As it is now, the second dropdown is populated at page load, which isn't what I want.

2. The first dropdown must pass it's selected text to a variabele at this point so I can build my sql query. The hardcoded query is in place, but I want to make it dynamically.

The complete code of the page is below. Please don't bash me for posting all (including javascript), but I need you to see the whole picture.

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim my_conn, rs, Frs, strSQL, FilterSQL
  3.  
  4. Set my_conn = createobject("ADODB.Connection")
  5. Set rs = Server.CreateObject("ADODB.Recordset") 
  6. Set Frs = Server.CreateObject("ADODB.Recordset") 
  7.  
  8. my_conn.open = "DRIVER={MySQL ODBC 3.51 Driver};"_
  9. & "SERVER=localhost;"_ 
  10. & "DATABASE=Uitleenregistratie;"_
  11. & "UID=root;PWD=XXXXXXX; OPTION=35;" 
  12.  
  13.  
  14.   'Create the SQL query
  15.   strSQL="select DISTINCT Specificatie from tblUitleen order by Specificatie"
  16.  
  17.   set rs = my_Conn.Execute(strSQL)
  18.  
  19. %>
  20.  
  21.  
  22. <html>
  23. <head>
  24. <title>NLR Uitleenregistratie - Selfprovisioning</title>
  25.  
  26. <script language=JavaScript>
  27. /**
  28. Originele DatePicker auteur:
  29. http://www.nsftools.com/tips/NotesTips.htm#datepicker
  30. */
  31.  
  32. var datePickerDivID = "datepicker";
  33. var iFrameDivID = "datepickeriframe";
  34.  
  35. var dayArrayShort = new Array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa');
  36. var dayArrayMed = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
  37. var dayArrayLong = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
  38. var monthArrayShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  39. var monthArrayMed = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec');
  40. var monthArrayLong = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  41.  
  42. // these variables define the date formatting we're expecting and outputting.
  43. // If you want to use a different format by default, change the defaultDateSeparator
  44. // and defaultDateFormat variables either here or on your HTML page.
  45. var defaultDateSeparator = "/";        // common values would be "/" or "."
  46. var defaultDateFormat = "mdy"    // valid values are "mdy", "dmy", and "ymd"
  47. var dateSeparator = defaultDateSeparator;
  48. var dateFormat = defaultDateFormat;
  49.  
  50. /**
  51. This is the main function you'll call from the onClick event of a button.
  52. Normally, you'll have something like this on your HTML page:
  53.  
  54. Start Date: <input name="StartDate">
  55. <input type=button value="select" onclick="displayDatePicker('StartDate');">
  56.  
  57. That will cause the datepicker to be displayed beneath the StartDate field and
  58. any date that is chosen will update the value of that field. If you'd rather have the
  59. datepicker display beneath the button that was clicked, you can code the button
  60. like this:
  61.  
  62. <input type=button value="select" onclick="displayDatePicker('StartDate', this);">
  63.  
  64. So, pretty much, the first argument (dateFieldName) is a string representing the
  65. name of the field that will be modified if the user picks a date, and the second
  66. argument (displayBelowThisObject) is optional and represents an actual node
  67. on the HTML document that the datepicker should be displayed below.
  68.  
  69. In version 1.1 of this code, the dtFormat and dtSep variables were added, allowing
  70. you to use a specific date format or date separator for a given call to this function.
  71. Normally, you'll just want to set these defaults globally with the defaultDateSeparator
  72. and defaultDateFormat variables, but it doesn't hurt anything to add them as optional
  73. parameters here. An example of use is:
  74.  
  75. <input type=button value="select" onclick="displayDatePicker('StartDate', false, 'dmy', '.');">
  76.  
  77. This would display the datepicker beneath the StartDate field (because the
  78. displayBelowThisObject parameter was false), and update the StartDate field with
  79. the chosen value of the datepicker using a date format of dd.mm.yyyy
  80. */
  81. function displayDatePicker(dateFieldName, displayBelowThisObject, dtFormat, dtSep)
  82. {
  83.   var targetDateField = document.getElementsByName (dateFieldName).item(0);
  84.  
  85.   // if we weren't told what node to display the datepicker beneath, just display it
  86.   // beneath the date field we're updating
  87.   if (!displayBelowThisObject)
  88.     displayBelowThisObject = targetDateField;
  89.  
  90.   // if a date separator character was given, update the dateSeparator variable
  91.   if (dtSep)
  92.     dateSeparator = dtSep;
  93.   else
  94.     dateSeparator = defaultDateSeparator;
  95.  
  96.   // if a date format was given, update the dateFormat variable
  97.   if (dtFormat)
  98.     dateFormat = dtFormat;
  99.   else
  100.     dateFormat = defaultDateFormat;
  101.  
  102.   var x = displayBelowThisObject.offsetLeft;
  103.   var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight ;
  104.  
  105.   // deal with elements inside tables and such
  106.   var parent = displayBelowThisObject;
  107.   while (parent.offsetParent) {
  108.     parent = parent.offsetParent;
  109.     x += parent.offsetLeft;
  110.     y += parent.offsetTop ;
  111.   }
  112.  
  113.   drawDatePicker(targetDateField, x, y);
  114. }
  115.  
  116.  
  117. /**
  118. Draw the datepicker object (which is just a table with calendar elements) at the
  119. specified x and y coordinates, using the targetDateField object as the input tag
  120. that will ultimately be populated with a date.
  121.  
  122. This function will normally be called by the displayDatePicker function.
  123. */
  124. function drawDatePicker(targetDateField, x, y)
  125. {
  126.   var dt = getFieldDate(targetDateField.value );
  127.  
  128.   // the datepicker table will be drawn inside of a <div> with an ID defined by the
  129.   // global datePickerDivID variable. If such a div doesn't yet exist on the HTML
  130.   // document we're working with, add one.
  131.   if (!document.getElementById(datePickerDivID)) {
  132.     // don't use innerHTML to update the body, because it can cause global variables
  133.     // that are currently pointing to objects on the page to have bad references
  134.     //document.body.innerHTML += "<div id='" + datePickerDivID + "' class='dpDiv'></div>";
  135.     var newNode = document.createElement("div");
  136.     newNode.setAttribute("id", datePickerDivID);
  137.     newNode.setAttribute("class", "dpDiv");
  138.     newNode.setAttribute("style", "visibility: hidden;");
  139.     document.body.appendChild(newNode);
  140.   }
  141.  
  142.   // move the datepicker div to the proper x,y coordinate and toggle the visiblity
  143.   var pickerDiv = document.getElementById(datePickerDivID);
  144.   pickerDiv.style.position = "absolute";
  145.   pickerDiv.style.left = x + "px";
  146.   pickerDiv.style.top = y + "px";
  147.   pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
  148.   pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
  149.   pickerDiv.style.zIndex = 10000;
  150.  
  151.   // draw the datepicker table
  152.   refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
  153. }
  154.  
  155.  
  156. /**
  157. This is the function that actually draws the datepicker calendar.
  158. */
  159. function refreshDatePicker(dateFieldName, year, month, day)
  160. {
  161.   // if no arguments are passed, use today's date; otherwise, month and year
  162.   // are required (if a day is passed, it will be highlighted later)
  163.   var thisDay = new Date();
  164.  
  165.   if ((month >= 0) && (year > 0)) {
  166.     thisDay = new Date(year, month, 1);
  167.   } else {
  168.     day = thisDay.getDate();
  169.     thisDay.setDate(1);
  170.   }
  171.  
  172.   // the calendar will be drawn as a table
  173.   // you can customize the table elements with a global CSS style sheet,
  174.   // or by hardcoding style and formatting elements below
  175.   var crlf = "\r\n";
  176.   var TABLE = "<table cols=7 class='dpTable'>" + crlf;
  177.   var xTABLE = "</table>" + crlf;
  178.   var TR = "<tr class='dpTR'>";
  179.   var TR_title = "<tr class='dpTitleTR'>";
  180.   var TR_days = "<tr class='dpDayTR'>";
  181.   var TR_todaybutton = "<tr class='dpTodayButtonTR'>";
  182.   var xTR = "</tr>" + crlf;
  183.   var TD = "<td class='dpTD' onMouseOut='this.className=\"dpTD\";' onMouseOver=' this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  184.   var TD_title = "<td colspan=5 class='dpTitleTD'>";
  185.   var TD_buttons = "<td class='dpButtonTD'>";
  186.   var TD_todaybutton = "<td colspan=7 class='dpTodayButtonTD'>";
  187.   var TD_days = "<td class='dpDayTD'>";
  188.   var TD_selected = "<td class='dpDayHighlightTD' onMouseOut='this.className=\"dpDayHighlightTD\";' onMouseOver='this.className=\"dpTDHover\";' ";    // leave this tag open, because we'll be adding an onClick event
  189.   var xTD = "</td>" + crlf;
  190.   var DIV_title = "<div class='dpTitleText'>";
  191.   var DIV_selected = "<div class='dpDayHighlight'>";
  192.   var xDIV = "</div>";
  193.  
  194.   // start generating the code for the calendar table
  195.   var html = TABLE;
  196.  
  197.   // this is the title bar, which displays the month and the buttons to
  198.   // go back to a previous month or forward to the next month
  199.   html += TR_title;
  200.   html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "&lt;") + xTD;
  201.   html += TD_title + DIV_title + monthArrayLong[ thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
  202.   html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "&gt;") + xTD;
  203.   html += xTR;
  204.  
  205.   // this is the row that indicates which day of the week we're on
  206.   html += TR_days;
  207.   for(i = 0; i < dayArrayShort.length; i++)
  208.     html += TD_days + dayArrayShort[i] + xTD;
  209.   html += xTR;
  210.  
  211.   // now we'll start populating the table with days of the month
  212.   html += TR;
  213.  
  214.   // first, the leading blanks
  215.   for (i = 0; i < thisDay.getDay(); i++)
  216.     html += TD + "&nbsp;" + xTD;
  217.  
  218.   // now, the days of the month
  219.   do {
  220.     dayNum = thisDay.getDate();
  221.     TD_onclick = " onclick=\"updateDateField('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
  222.  
  223.     if (dayNum == day)
  224.       html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
  225.     else
  226.       html += TD + TD_onclick + dayNum + xTD;
  227.  
  228.     // if this is a Saturday, start a new row
  229.     if (thisDay.getDay() == 6)
  230.       html += xTR + TR;
  231.  
  232.     // increment the day
  233.     thisDay.setDate(thisDay.getDate() + 1);
  234.   } while (thisDay.getDate() > 1)
  235.  
  236.   // fill in any trailing blanks
  237.   if (thisDay.getDay() > 0) {
  238.     for (i = 6; i > thisDay.getDay(); i--)
  239.       html += TD + "&nbsp;" + xTD;
  240.   }
  241.   html += xTR;
  242.  
  243.   // add a button to allow the user to easily return to today, or close the calendar
  244.   var today = new Date();
  245.   var todayString = "Today is " + dayArrayMed[today.getDay()] + ", " + monthArrayMed[ today.getMonth()] + " " + today.getDate();
  246.   html += TR_todaybutton + TD_todaybutton;
  247.   html += "<button class='dpTodayButton' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>Huidig</button> ";
  248.   html += "<button class='dpTodayButton' onClick='updateDateField(\"" + dateFieldName + "\");'>Sluiten</button>";
  249.   html += xTD + xTR;
  250.  
  251.   // and finally, close the table
  252.   html += xTABLE;
  253.  
  254.   document.getElementById(datePickerDivID).innerHTML = html;
  255.   // add an "iFrame shim" to allow the datepicker to display above selection lists
  256.   adjustiFrame();
  257. }
  258.  
  259.  
  260. /**
  261. Convenience function for writing the code for the buttons that bring us back or forward
  262. a month.
  263. */
  264. function getButtonCode(dateFieldName, dateVal, adjust, label)
  265. {
  266.   var newMonth = (dateVal.getMonth () + adjust) % 12;
  267.   var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
  268.   if (newMonth < 0) {
  269.     newMonth += 12;
  270.     newYear += -1;
  271.   }
  272.  
  273.   return "<button class='dpButton' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</button>";
  274. }
  275.  
  276.  
  277. /**
  278. Convert a JavaScript Date object to a string, based on the dateFormat and dateSeparator
  279. variables at the beginning of this script library.
  280. */
  281. function getDateString(dateVal)
  282. {
  283.   var dayString = "00" + dateVal.getDate();
  284.   var monthString = "00" + (dateVal.getMonth()+1);
  285.   dayString = dayString.substring(dayString.length - 2);
  286.   monthString = monthString.substring(monthString.length - 2);
  287.  
  288.   switch (dateFormat) {
  289.     case "dmy" :
  290.       return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
  291.     case "ymd" :
  292.       return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
  293.     case "mdy" :
  294.     default :
  295.       return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
  296.   }
  297. }
  298.  
  299.  
  300. /**
  301. Convert a string to a JavaScript Date object.
  302. */
  303. function getFieldDate(dateString)
  304. {
  305.   var dateVal;
  306.   var dArray;
  307.   var d, m, y;
  308.  
  309.   try {
  310.     dArray = splitDateString(dateString);
  311.     if (dArray) {
  312.       switch (dateFormat) {
  313.         case "dmy" :
  314.           d = parseInt(dArray[0], 10);
  315.           m = parseInt(dArray[1], 10) - 1;
  316.           y = parseInt(dArray[2], 10);
  317.           break;
  318.         case "ymd" :
  319.           d = parseInt(dArray[2], 10);
  320.           m = parseInt(dArray[1], 10) - 1;
  321.           y = parseInt(dArray[0], 10);
  322.           break;
  323.         case "mdy" :
  324.         default :
  325.           d = parseInt(dArray[1], 10);
  326.           m = parseInt(dArray[0], 10) - 1;
  327.           y = parseInt(dArray[2], 10);
  328.           break;
  329.       }
  330.       dateVal = new Date(y, m, d);
  331.     } else if (dateString) {
  332.       dateVal = new Date(dateString);
  333.     } else {
  334.       dateVal = new Date();
  335.     }
  336.   } catch(e) {
  337.     dateVal = new Date();
  338.   }
  339.  
  340.   return dateVal;
  341. }
  342.  
  343.  
  344. /**
  345. Try to split a date string into an array of elements, using common date separators.
  346. If the date is split, an array is returned; otherwise, we just return false.
  347. */
  348. function splitDateString(dateString)
  349. {
  350.   var dArray;
  351.   if (dateString.indexOf("/") >= 0)
  352.     dArray = dateString.split("/");
  353.   else if (dateString.indexOf(".") >= 0)
  354.     dArray = dateString.split(".");
  355.   else if (dateString.indexOf("-") >= 0)
  356.     dArray = dateString.split("-");
  357.   else if (dateString.indexOf("\\") >= 0)
  358.     dArray = dateString.split("\\");
  359.   else
  360.     dArray = false;
  361.  
  362.   return dArray;
  363. }
  364.  
  365. /**
  366. Update the field with the given dateFieldName with the dateString that has been passed,
  367. and hide the datepicker. If no dateString is passed, just close the datepicker without
  368. changing the field value.
  369.  
  370. Also, if the page developer has defined a function called datePickerClosed anywhere on
  371. the page or in an imported library, we will attempt to run that function with the updated
  372. field as a parameter. This can be used for such things as date validation, setting default
  373. values for related fields, etc. For example, you might have a function like this to validate
  374. a start date field:
  375.  
  376. function datePickerClosed(dateField)
  377. {
  378.   var dateObj = getFieldDate(dateField.value);
  379.   var today = new Date();
  380.   today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
  381.  
  382.   if (dateField.name == "StartDate") {
  383.     if (dateObj < today) {
  384.       // if the date is before today, alert the user and display the datepicker again
  385.       alert("Please enter a date that is today or later");
  386.       dateField.value = "";
  387.       document.getElementById(datePickerDivID).style.visibility = "visible";
  388.       adjustiFrame();
  389.     } else {
  390.       // if the date is okay, set the EndDate field to 7 days after the StartDate
  391.       dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
  392.       var endDateField = document.getElementsByName ("EndDate").item(0);
  393.       endDateField.value = getDateString(dateObj);
  394.     }
  395.   }
  396. }
  397.  
  398. */
  399. function updateDateField(dateFieldName, dateString)
  400. {
  401.   var targetDateField = document.getElementsByName (dateFieldName).item(0);
  402.   if (dateString)
  403.     targetDateField.value = dateString;
  404.  
  405.   var pickerDiv = document.getElementById(datePickerDivID);
  406.   pickerDiv.style.visibility = "hidden";
  407.   pickerDiv.style.display = "none";
  408.  
  409.   adjustiFrame();
  410.   targetDateField.focus();
  411.  
  412.   // after the datepicker has closed, optionally run a user-defined function called
  413.   // datePickerClosed, passing the field that was just updated as a parameter
  414.   // (note that this will only run if the user actually selected a date from the datepicker)
  415.   if ((dateString) && (typeof(datePickerClosed) == "function"))
  416.     datePickerClosed(targetDateField);
  417. }
  418.  
  419.  
  420. function datePickerClosed(dateField)
  421. {
  422.   var dateObj = getFieldDate(dateField.value);
  423.   var today = new Date();
  424.   today = new Date(today.getFullYear(), today.getMonth(), today.getDate());
  425.  
  426.   if (dateField.name == "BeginDatum") {
  427.     if (dateObj < today) {
  428.       // if the date is before today, alert the user and display the datepicker again
  429.       alert("De gekozen datum ligt in het verleden!");
  430.       dateField.value = "";
  431.       document.getElementById(datePickerDivID).style.visibility = "visible";
  432.       adjustiFrame();
  433.     } else {
  434.       // if the date is okay, set the EndDate field to 7 days after the StartDate
  435.       dateObj.setTime(dateObj.getTime() + (7 * 24 * 60 * 60 * 1000));
  436.       var endDateField = document.getElementsByName ("EindDatum").item(0);
  437.       endDateField.value = getDateString(dateObj);
  438.     }
  439.   }
  440. }
  441.  
  442.  
  443. /**
  444. Use an "iFrame shim" to deal with problems where the datepicker shows up behind
  445. selection list elements, if they're below the datepicker. The problem and solution are
  446. described at:
  447.  
  448. http://dotnetjunkies.com/WebLog/jkin...07/21/488.aspx
  449. http://dotnetjunkies.com/WebLog/jkin...0/30/2975.aspx
  450. */
  451. function adjustiFrame(pickerDiv, iFrameDiv)
  452. {
  453.   // we know that Opera doesn't like something about this, so if we
  454.   // think we're using Opera, don't even try
  455.   var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
  456.   if (is_opera)
  457.     return;
  458.  
  459.   // put a try/catch block around the whole thing, just in case
  460.   try {
  461.     if (!document.getElementById(iFrameDivID)) {
  462.       // don't use innerHTML to update the body, because it can cause global variables
  463.       // that are currently pointing to objects on the page to have bad references
  464.       //document.body.innerHTML += "<iframe id='" + iFrameDivID + "' src='javascript:false;' scrolling='no' frameborder='0'>";
  465.       var newNode = document.createElement("iFrame");
  466.       newNode.setAttribute("id", iFrameDivID);
  467.       newNode.setAttribute("src", "javascript:false;");
  468.       newNode.setAttribute("scrolling", "no");
  469.       newNode.setAttribute ("frameborder", "0");
  470.       document.body.appendChild(newNode);
  471.     }
  472.  
  473.     if (!pickerDiv)
  474.       pickerDiv = document.getElementById(datePickerDivID);
  475.     if (!iFrameDiv)
  476.       iFrameDiv = document.getElementById(iFrameDivID);
  477.  
  478.     try {
  479.       iFrameDiv.style.position = "absolute";
  480.       iFrameDiv.style.width = pickerDiv.offsetWidth;
  481.       iFrameDiv.style.height = pickerDiv.offsetHeight ;
  482.       iFrameDiv.style.top = pickerDiv.style.top;
  483.       iFrameDiv.style.left = pickerDiv.style.left;
  484.       iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
  485.       iFrameDiv.style.visibility = pickerDiv.style.visibility ;
  486.       iFrameDiv.style.display = pickerDiv.style.display;
  487.     } catch(e) {
  488.     }
  489.  
  490.   } catch (ee) {
  491.   }
  492.  
  493. }
  494.  
  495.  
  496. </script>
  497.  
  498. <style>
  499. body {
  500.     font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
  501.     font-size: .8em;
  502.     }
  503.  
  504. /* the div that holds the date picker calendar */
  505. .dpDiv {
  506.     }
  507.  
  508.  
  509. /* the table (within the div) that holds the date picker calendar */
  510. .dpTable {
  511.     font-family: Tahoma, Arial, Helvetica, sans-serif;
  512.     font-size: 12px;
  513.     text-align: center;
  514.     color: #505050;
  515.     background-color: #ece9d8;
  516.     border: 1px solid #AAAAAA;
  517.     }
  518.  
  519.  
  520. /* a table row that holds date numbers (either blank or 1-31) */
  521. .dpTR {
  522.     }
  523.  
  524.  
  525. /* the top table row that holds the month, year, and forward/backward buttons */
  526. .dpTitleTR {
  527.     }
  528.  
  529.  
  530. /* the second table row, that holds the names of days of the week (Mo, Tu, We, etc.) */
  531. .dpDayTR {
  532.     }
  533.  
  534.  
  535. /* the bottom table row, that has the "This Month" and "Close" buttons */
  536. .dpTodayButtonTR {
  537.     }
  538.  
  539.  
  540. /* a table cell that holds a date number (either blank or 1-31) */
  541. .dpTD {
  542.     border: 1px solid #ece9d8;
  543.     }
  544.  
  545.  
  546. /* a table cell that holds a highlighted day (usually either today's date or the current date field value) */
  547. .dpDayHighlightTD {
  548.     background-color: #CCCCCC;
  549.     border: 1px solid #AAAAAA;
  550.     }
  551.  
  552.  
  553. /* the date number table cell that the mouse pointer is currently over (you can use contrasting colors to make it apparent which cell is being hovered over) */
  554. .dpTDHover {
  555.     background-color: #aca998;
  556.     border: 1px solid #888888;
  557.     cursor: pointer;
  558.     color: red;
  559.     }
  560.  
  561.  
  562. /* the table cell that holds the name of the month and the year */
  563. .dpTitleTD {
  564.     }
  565.  
  566.  
  567. /* a table cell that holds one of the forward/backward buttons */
  568. .dpButtonTD {
  569.     }
  570.  
  571.  
  572. /* the table cell that holds the "This Month" or "Close" button at the bottom */
  573. .dpTodayButtonTD {
  574.     }
  575.  
  576.  
  577. /* a table cell that holds the names of days of the week (Mo, Tu, We, etc.) */
  578. .dpDayTD {
  579.     background-color: #CCCCCC;
  580.     border: 1px solid #AAAAAA;
  581.     color: white;
  582.     }
  583.  
  584.  
  585. /* additional style information for the text that indicates the month and year */
  586. .dpTitleText {
  587.     font-size: 12px;
  588.     color: gray;
  589.     font-weight: bold;
  590.     }
  591.  
  592.  
  593. /* additional style information for the cell that holds a highlighted day (usually either today's date or the current date field value) */ 
  594. .dpDayHighlight {
  595.     color: 4060ff;
  596.     font-weight: bold;
  597.     }
  598.  
  599.  
  600. /* the forward/backward buttons at the top */
  601. .dpButton {
  602.     font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
  603.     font-size: 10px;
  604.     color: gray;
  605.     background: #d8e8ff;
  606.     font-weight: bold;
  607.     padding: 0px;
  608.     }
  609.  
  610.  
  611. /* the "This Month" and "Close" buttons at the bottom */
  612. .dpTodayButton {
  613.     font-family: Verdana, Tahoma, Arial, Helvetica, sans-serif;
  614.     font-size: 10px;
  615.     color: gray;
  616.     background: #d8e8ff;
  617.     font-weight: bold;
  618.     }
  619.  
  620. </style>
  621.  
  622. </head>
  623.  
  624. <body>
  625.  
  626. <p>
  627. <p>
  628. <p>
  629. <p>
  630. <img border="0" src="images/LogoNLR.bmp" width="546" height="101"><p>
  631. &nbsp;<p align="center">
  632. <b><font size="5">Reserveringen</font></b><p align="center">
  633. &nbsp;<p>
  634.  
  635. <p>
  636.  
  637. <p>
  638.  
  639. <p>
  640.  
  641. <p>
  642.  
  643. <p>
  644.  
  645. <div align="center">
  646.     <table border="4" width="31%" style="border-collapse: collapse" id="table2">
  647.         <tr>
  648.             <td>
  649.             <div align="center">
  650.                 <table border="0" width="36%" id="table3" style="border-collapse: collapse">
  651.     <tr>
  652.         <td colspan="3">
  653.         &nbsp;</td>
  654.     </tr>
  655.     <tr>
  656.         <td colspan="3">
  657.         <font color="#0000FF" style="font-size: 9pt">Kies een gewenste begindatum en einddatum. 
  658. Uitleenobjecten zullen vervolgens gecontroleerd worden op beschikbaarheid.</font></td>
  659.     </tr>
  660.     <tr>
  661.         <td width="11%" align="center">
  662. <p align="left">
  663. <b><font size="2">Begindatum:</font></b></td>
  664.         <td width="17%" align="center">
  665.         <p align="center"> <input name="BeginDatum"></td>
  666.         <td width="14%" align="center">&nbsp;<input type=button value="Selecteren" onclick="displayDatePicker('BeginDatum');">
  667.         </td>
  668.     </tr>
  669.     <tr>
  670.         <td width="11%" align="center">
  671.         <p align="left"><b><font size="2">Einddatum:</font> </b></td>
  672.         <td width="17%" align="center">
  673.         <p align="center"><input name="EindDatum"></td>
  674.         <td width="14%" align="center">&nbsp;<input type=button value="Selecteren" onclick="displayDatePicker('EindDatum');">
  675.         </td>
  676.     </tr>
  677. </table>
  678.             </div>
  679.             <div align="center">
  680.                 <table border="0" width="94%" id="table4" style="border-collapse: collapse">
  681.     <tr>
  682.         <td colspan="3">
  683.         &nbsp;</td>
  684.     </tr>
  685.     <tr>
  686.         <td colspan="3">
  687.         &nbsp;</td>
  688.     </tr>
  689.     <tr>
  690.         <td colspan="3">
  691.         <font color="#0000FF"><span style="font-size: 9pt">Type</span></font><font style="font-size: 9pt" color="#0000FF"> uitleenobject:
  692.         </font></td>
  693.     </tr>
  694.     <tr>
  695.         <td width="27%" align="center">
  696. <p align="left">
  697. <font size="2"><b>Categorie</b></font><b><font size="2">:</font></b></td>
  698.         <td width="40%" align="center">
  699.         <p align="left"> 
  700.  
  701.       <select name="D1" onChange="<I'm stuck here!></I'm>" > 
  702.  
  703.  
  704. <%
  705.     Do While Not rs.EOF 
  706.         Response.Write "<option value='" & rs("Specificatie") &"'>"& rs("Specificatie") &"</option>"
  707.     rs.MoveNext
  708.     Loop
  709.  
  710.  
  711.     rs.Close
  712.  
  713. %>
  714.  
  715.  
  716. </select></td>
  717.         <td width="31%" align="center">&nbsp;
  718.         </td>
  719.     </tr>
  720.     <tr>
  721.         <td width="59%" align="center" colspan="3">
  722.         <p align="left">&nbsp;</td>
  723.     </tr>
  724. </table>
  725.             </div>
  726.             <div align="center">
  727.                 <table border="0" width="94%" id="table5" style="border-collapse: collapse">
  728.     <tr>
  729.         <td colspan="2">
  730.         &nbsp;</td>
  731.     </tr>
  732.     <tr>
  733.         <td colspan="2">
  734.         <p align="left">
  735.         <font color="#0000FF"><span style="font-size: 9pt">Beschikbare</span></font><font style="font-size: 9pt" color="#0000FF"> uitleenobjecten:</font></td>
  736.     </tr>
  737.     <tr>
  738.         <td width="27%" align="center">
  739. <p align="left">
  740. <b><font size="2">Object:</font></b></td>
  741.         <td width="72%" align="center">
  742.         <p align="left"> 
  743.  
  744. <%
  745.  
  746. 'Create the SQL query
  747.   strSQL="SELECT DISTINCT Object from `tblUitleen` WHERE `Specificatie` = '" & "Laptop (This will become a variabele dependant on other dropdownbox)" & "' AND (NOT((`Datum terug` <= '2008-08-29') OR (`Datum uitgeleend` >= '2008-08-06')));" 
  748.  
  749. set rs = my_conn.Execute(strSQL)
  750.  
  751. Do WHILE NOT rs.EOF
  752.     if nFilter="" then
  753.         nFilter = rs("Object")
  754.     else
  755.         nFilter = nFilter & "," & rs("Object")
  756.     end if
  757. rs.MoveNext
  758. Loop
  759. rs.close
  760.  
  761.  
  762. if instr(nFilter,",") then
  763.     xFilter = split(nFilter,",")
  764.     for i = 0 to ubound(xFilter)
  765.         if PartialSQL ="" then
  766.             PartialSQL = "`Object`<> '" & xFilter(i) & "'"
  767.         else
  768.             PartialSQL = PartialSQL & "AND `Object`<> '" & xFilter(i) & "'"
  769.         end if
  770.     Next
  771.  
  772.     FilterSQL = "Select DISTINCT Object from tblUitleen WHERE " & partialSQL & " AND `Specificatie`='Laptop' ORDER BY Object" 
  773.  
  774. else
  775.     FilterSQL = "Select DISTINCT Object from tblUitleen WHERE `Object`<> '" & nFilter & "' AND `Specificatie`='Laptop' ORDER BY Object" 
  776. end if
  777.  
  778.  
  779.  
  780. set Frs = my_conn.Execute(filterSQL)
  781. Response.Write "<select name=Specs><option value='''' selected>Beschikbare uitleenobjecten:</option>"
  782. Do while Not Frs.EOF            
  783.     Response.Write "<option value=''" & Frs("Object") &"''>"& Frs("Object") &"</option>"
  784. Frs.MoveNext
  785. Loop
  786.  
  787.  
  788. Response.Write "</select>"
  789.  
  790. Frs.close
  791. my_conn.Close
  792.  
  793. %> 
  794.  
  795.  
  796. </select>&nbsp;
  797.         </td>
  798.     </tr>
  799.     <tr>
  800.         <td width="59%" align="center" colspan="2">
  801.         <p><font style="font-size: 7pt; font-weight:700" color="#FF0000"> <u>
  802.         Visueel Overzicht</u> | <u>Object Info</u></font></td>
  803.     </tr>
  804. </table>
  805.                 <p align="left"><font style="font-size: 9pt" color="#0000FF">&nbsp;<%="<font color='red'>" & request("ResObject") & "</font>"%></font></div>
  806.  
  807. </body>
  808. </html>
  809.  
Thank you in advance for your help.

Hans
The Netherlands
Aug 11 '08 #1
4 4541
Anyone..................Please??? I really need help
Aug 11 '08 #2
jeffstl
432 Expert 256MB
The problem here offhand seems to be that your trying to combine the use of javascript (which runs on the CLIENT side) and asp.net code (which runs on the SERVER side).

You cannot share variables between the two, atleast not in any conventional way. You would have to take the value populated from a drop down choice in the on change event, with an ASP.NET web control instead of a normal HTML form control.

With an ASP.NET web control the onchange event can be handled on the server side and return the necessary data to the page.

I could be wrong because I didn't go through all that code, but just a quick guess.

If you want more assistance please let me know but try to narrow down the code to just where the event actually is your talking about, and the code that handles that event and maybe I can explain better.
Aug 12 '08 #3
jeffstl
432 Expert 256MB
oops.... I see now you are using classic ASP not asp.net

Which is fine but the same problem still exists.

In this case you would need to use the onchange event to populate a HIDDEN text field maybe with a redirect and a querystring pass?

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" value=<%=request.querystring("JavaPassedValue")%>>
  2.  
Aug 12 '08 #4
jhardman
3,406 Expert 2GB
I second what jeff said. there are a couple possibilities i often see.

1- you could load all of the possible second queries but keep them hidden, then when the user makes his choice you just have to unhide the one. this takes a bit of javascript, but isn't especially hard, especially if there are only a few possibilities on the first option.

2- onchange submit the form. your form handler should send back the exact same form with his previous inputs already selected, plus the next step prepared. This method requires a good grasp of asp and only uses small amounts of javascript.

3- advanced javascript and ajax could be used to populate the second select input by reconnecting to the server onchange. notice, this is an advanced topic, i couldn't offer you any help on how to implement it, but in theory it should work.

jared
Aug 13 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: leegold2 | last post by:
Appreciate any help- I want to make a 1st DB query, then I want to feed those results into a second query - the results of the 2nd query are then my output. I know it's possible w/a temporary...
6
by: frizzle | last post by:
Hi there I'm building this CMS, and at a point i have 3 similar drop downs. The values of the drop downs are called from a MysqlDB. The first one is just fine: do{ $selected = ($_GET ==...
1
by: seanmayhew | last post by:
Im attempting to get the vaules for the second drop down on index changed of the first. This works fine. However rather than just replacing the values of the second drop down with the new values...
1
by: leen | last post by:
hola.. hi..i got a problem..i have make a query for a table..the problem is..i want to add a field from another table(i mean different table from the table that i make the query)...but the table...
5
by: Sorin Marin | last post by:
Hi Experts, I have some Oracle views linked in an Access database ¬ this is the good part. Now I try to link to an Access query from other database (still Access) but I have no clue how. I'm a bit...
0
by: acadam | last post by:
Hi, I am trying to use cascading dropdown but I have some problems. The firts dropdown is ok, it's filled regularly... but the second dropdown is still disabled!! Why? I tried to start my...
6
by: cretaceous | last post by:
Hi I'm a php/mysql developer and struggle when it comes to javascript ! I've looked all over for a solution but am rubbish at adapting javascript I've got two select dropdowns in a form The...
1
by: bobf | last post by:
I have successfully linked 2 dropdown lists, but then I got greedy and wanted to provide the same information to further dropdown boxes. What I am trying to do is to select a client and then offer...
2
by: John Lewis | last post by:
I have created a windows form application using an Access 2003 db. I used the drag and drop methods to place the fields on the forms and the same with the second form using the related table from the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.