combo box doesnt work in IE7 but Firefox
Hi all,
I was able to combine my dynamic drop down list to work with the data display.
However it only works in Firefox and Opera.
In IE7 i get to populate the Island list bit then it doesn't load the Dynamic hotel list.
I figure it might be something with the javascript and IE?
Or the way the form submits to populate the second box?
Maybe someone has an answer on what to change / amend?
The code is this:
<%@ Language = VBScript %>
<%Option Explicit%>
<%Response.Buffer = True%>
<HTML>
<HEAD>
<TITLE></TITLE>
<STYLE type="text/css">
@media all {
body, table, input {font-family: Arial; font-size: 9pt;}
h1 {font-family: Arial; font-size: 12pt; font-weight: bold;}
h2 {font-family: Arial; font-size: 10pt; font-weight: bold;}
/* General settings for tabel */
table {margin: 10px 0 10px 0; border-collapse: collapse;}
td {padding: 1px 4px 1px 0px; border: solid white; border-width: 2px 2px 2px 0;}
th {padding: 1px 4px 1px 0px; border: solid white; border-width: 2px 2px 2px 0; font-style: normal; font-weight: normal;}
}
</style>
<%
Dim strDBinfo
Dim objConnection
Dim strIsland
Dim strHotel
Dim strSelected
Dim objRS
Dim strSQL
Dim SelectedHotel
Dim rs
Dim hotelsql
Dim count
Dim i_last
Dim bgcolor
strIsland = Request.Form("Island")
strHotel = Request.Form("SelectedHotel")
strDBinfo = "DBQ=" & Server.Mappath("test2007.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
if not IsObject("ojbConnection") then
set objConnection=Server.CreateObject("ADODB.Connectio n")
objConnection.ConnectionTimeout = 15
objConnection.CommandTimeout = 10
objConnection.Mode = 3 'adModeReadWrite
if objConnection.state = 0 then
objConnection.Open strDBinfo
end if
end if
sub makeIsland()
if not isObject("objRS") then
set objRS=Server.CreateObject("ADODB.RecordSet")
end if
if objRS.state <> 0 then
objRS.close
end if
strSQL = "SELECT DISTINCT Island FROM Hawaii ORDER BY Island"
objRS.open strSQL,objConnection,3,3
Response.Write("<option>Start by selecting an Island here</option>" & VBCRLF )
do while not objRS.EOF
if objRS("Island") = strIsland then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & objRS("Island") & "</option>" & VBCRLF )
objRS.MoveNext
loop
objRS.Close
set objRS=Nothing
end sub
sub makeHotel()
if strIsland <> "" then
if not isObject("objRS") then
set objRS=Server.CreateObject("ADODB.RecordSet")
end if
if objRS.state <> 0 then
objRS.close
end if
strSQL = "SELECT DISTINCT Hotel FROM Hawaii WHERE Island = '" & strIsland & "' ORDER BY Hotel"
objRS.Open strSQL,objConnection,3,3
if objRS.eof then
Response.Write("<option>No Hotels found</option>")
else
Response.Write("<option>Select a hotel</option>" & VBCRLF )
do while not objRS.EOF
if objRS("Hotel") = strHotel then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" & objRS("Hotel") & "</option>" & VBCRLF )
objRS.MoveNext
loop
end if
objRS.Close
set objRS=Nothing
else
Response.Write("<option></option>")
end if
end sub
%>
<% SelectedHotel = Request.Form("SelectedHotel") %>
<SCRIPT LANGUAGE=javascript>
<!--
function submitIsland(){
var objForm = document.forms[0];
objForm.elements['Hotel'].selectedIndex=0;
objForm.submit();
}
function submitForm(){
var objForm=document.forms[0];
objForm.submit();
return true;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<p align="center"><h1>Hawaii Database 2007</h1></p>
<FORM action="" method=POST id=form1 name=SelectedHotel onchange="submitForm()">
<table border="0" width="100%" id="table1">
<tr>
<td width="132">Hawaii Island</td>
<td> <SELECT name="Island" onChange="submitIsland()">
<%call makeIsland%>
</SELECT></td>
</tr>
<tr>
<td>Hotels</td>
<td> <SELECT name="SelectedHotel" onChange="submitForm();">
<%call makeHotel%>
</SELECT></td>
</tr>
<tr>
</tr>
</table>
</FORM>
<%
'Set DataConn = Server.CreateObject("ADODB.Connection")
'DataConn.Open "DBQ=" & Server.Mappath("test2007.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")
' Select all data from the table and display only the selected hotel
hotelsql = "select * from Hawaii where Hotel = '" & SelectedHotel & "' ORDER BY RoomType, DateFrom"
' Execute the sql
rs.Open hotelsql, strDBinfo
%>
<div align="center">
<table BORDER="0" width="100%" height="30" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#000000" style="border-collapse: collapse" cellpadding="3" cellspacing="1">
<p align="left">
<b><% =Request.Form("SelectedHotel")%></b><br>
</p>
<tr>
<td align="center" bgcolor="#00FFCC"><b>City</b></td>
<td align="center" bgcolor="#00FFCC"><b>Stars</b></td>
<td align="center" bgcolor="#00FFCC"><b>Room Type</b></td>
<td align="center" bgcolor="#00FFCC"><b>From</b></td>
<td align="center" bgcolor="#00FFCC"><b>To</b></td>
<td align="center" bgcolor="#00FFCC"><b>Single</b></td>
<td align="center" bgcolor="#00FFCC"><b>Twin</b></td>
<td align="center" bgcolor="#00FFCC"><b>Triple</b></td>
<td align="center" bgcolor="#00FFCC"><b>Quad</b></td>
<td align="center" bgcolor="#00FFCC"><b>Child</b></td>
<td align="center" bgcolor="#00FFCC"><b>PayNts</b></td>
<td align="center" bgcolor="#00FFCC"><b>GetNts</b></td>
<td align="center" bgcolor="#00FFCC"><b>Notes</b></td>
<td align="center" bgcolor="#00FFCC"><b>Notes</b></td>
</tr>
<%
' Move to the first record
IF RS.BOF AND RS.EOF THEN
response.write "Please select a hotel first"
ELSE
rs.movefirst
' Start a loop that will end with the last record
do while not rs.eof
' Simple counter that adds one for each observation in the record set
count=count + 1
' Looks for the last digit in the count variable
i_last=right(count,1)
' If the last digit of the variable count is an odd number
' then make the background this #color
select case i_last
case "1","3","5","7","9"
bgcolor = "#EEEEDD"
' If not make the background this #color
case else
bgcolor = "#DDDDBB"
end select
%>
<tr bgcolor="<%= bgcolor%>">
<td height="6" align="center">
<%= rs("Location") %>
</td>
<td align="center" height="6">
<%= rs("Stars") %>
</td>
<td align="center" height="6">
<%= rs("Roomtype") %>
</td>
<td align="center" height="6">
<%= rs("DateFrom") %>
</td>
<td align="center" height="6">
<%= rs("DateTo") %>
</td>
<td align="center" height="6">
<%= rs("Single") %>
</td>
<td align="center" height="6">
<%= rs("Twin") %>
</td>
<td align="center" height="6">
<%= rs("Triple") %>
</td>
<td align="center" height="6">
<%= rs("Quad") %>
</td>
<td align="center" height="6">
<%= rs("Child") %>
</td>
<td align="center" height="6">
<%= rs("PayNights") %>
</td>
<td align="center" height="6">
<%= rs("GetNights") %>
</td>
<td height="6">
<%= rs("Notes1") %>
</td>
<td height="6">
<%= rs("Notes2") %>
</td>
</tr>
<%
' Move to the next record
rs.movenext
' Loop back to the do statement and end
loop
END IF
%>
</table>
</div>
<br>
<b><% =Request.Form("SelectedHotel")%></b>
</body>
</html>
<%
' Close and set the recordset to nothing
rs.close
set rs=nothing
%>
|