Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Problem in using dependent dropdown list


Message #1 by "Joe Lee" <bugmania76@y...> on Tue, 3 Sep 2002 13:45:24
Sorry to bother again, i have 2 more problems in hand. This is in regards
in using asp to simulate the dynamic drop down menu. 
It seems that i cannot get the previous selected box to stay in its place 
when the form gets submited again.
This are the codes:
Basically, what the form does is to request the user to choose a year, and 
resubmit again to retrieve the month for the year and again to choose the 
question based on the month and year.


Dropdown 1:
<select name="year" onChange="subFrm()">
<option value="">Please Select Year</option>
<% do until rs.EOF %>
<% If yearfield = "" Then %>
<OPTION value='<%=rs("year")%>'><%=rs("year")%></OPTION>
<% Else %>
<OPTION selected value='<%=rs("year")%>'><%=rs("year")%></OPTION>
<% End If %>
<% rs.movenext 
loop %>
</select>

************************************************************************

Dropdown 2:
<% If yearfield <> "" Then %>
<% 
strSQL = "SELECT month FROM survey_stat WHERE year like '%" 
strSQL = strSQL & Replace(yearfield, "'", "''") & "%'"  
strSQL = strSQL & " GROUP BY month ORDER BY month ASC"
Set rs = objConn.Execute(strSQL) %>

<select name="month" onChange="subFrm()">
<OPTION  value="<%=Request("month")%>"><%=Request("month")%></OPTION>
<% do until rs.EOF %>
<% If monthfield <> "" Then %>
<OPTION value=<%=rs("month")%>><%=rs("month")%></OPTION>
<% Else %>
<OPTION value='<%=rs("month")%>'><%=rs("month")%></OPTION>
<% End If %>
<% rs.movenext 
   loop %>
</select>

************************************************************************
Drop downlist 3:
<select name="surveyCode">
<% do until rs.EOF %>
<OPTION selected value='<%=rs("survey_code")%>'><%=rs("survey_code")%
>.&nbsp;<%=rs("code_description")%></OPTION>
<% rs.movenext 
	loop %>
</select> 
<% Else %>
<Select name="ques">
<option selected value="">--</option>
</Select> 
                   

*************************************************************************
Problem 2:

Also, there's a bit of problem with my form valdation when i try to ensure 
the user select the month field. I uses javascript to validate the form,

This is my code and it will be call upon once the form is submitted.
The error it reports is it could not find the relevent form object, in 
this case , the month field. 
I wonder is it because of the multiplesubmit problem?

function surveyValidate()
{
var validated = true;
  if (chkExist(document.form1.month, 'Month') == false) 
      validated = false;
       return validated;
}

Regards, 
Joe

  Return to Index