lucky20
November 22, 2010, 8:30pm
1
Hi…
I am doing an application with two dropdown boxes.
Once we change the value of first drop down using database values ,the values in the second drop down should change…then click on done it should display the data from databse…
first dropdown :contains country names
second dropdown :contains city of particular country…
Can any one know how to do this in javascript…
My problem here at is displaying values on second drop down based on first drop down selection:
Can any one help me here if you know?
Thanks
system
November 22, 2010, 8:51pm
2
Do you want to populate the second drop down without a page refresh?
If yes, then you will have to use AJAX
lucky20
November 22, 2010, 8:55pm
3
yes…
But i don’t want to use ajax…I need this to be in javascript/classic ASP…
I don’t know ajax to use…
any help regarding this is appericiated…
Thanks
system
November 22, 2010, 10:21pm
4
since the answer is yes, then you have no option but to use ajax afaik.
I need this to be in javascript/classic ASP…
but ajax is not a different or new language. it is simply a particular way of using javascript.
If you want to learn how to use ajax, which truely is a subset of javascript, the following book proves to be incredibly useful.
Bulletproof AJAX which also includes [url=“http://bulletproofajax.com/code/”]code and demos .
If you don’t want to roll your own code, you can make use of pre-existing libraries that help to simplify the process, such as with jQuery’s ajax
lucky20
November 23, 2010, 1:43pm
7
can anyone find out the error where it was…Can anyone explain the code…
The output is not the desired one…
<html>
<script language="javascript">
function listboxchange(p_index)
{
<%
OpenSqlConn
mySQL = "SELECT * FROM menu Order By menuid "
'Get Recordset using our SQL
Set myRS = Conn.Execute(mySQL)
%>
switch (p_index)
{
<%
'Loop Through all authors and books
Do Until myRS.eof
StartAuthor = myRS("menuid")
Cnt = 0
%>
case "<%=StartAuthor%>" :
<%
do until myrs.eof or StartAuthor <> myRS("menuid")
%>
document.myform.listbox2.options[<%=cnt%>]=new Option("<%=myRs("sizeid")%>","<%=myRs("size")%>");
<%
Cnt = Cnt + 1
myrs.movenext
if myrs.eof then exit do
Loop
%>
break;
<%
Loop
%>
}
return true;
}
</script>
<%
mySQL = "SELECT DISTINCT menuid FROM menu Order By menuid asc"
Set myRS = Conn.Execute(mySQL)
do until myrs.eof
ListBox1 = ListBox1 & "<option value=""" & myRs("menuid") & """>" & myRs("menuid") & "</option>"
myRs.movenext
loop
myRS.close
Set myRS = nothing
Conn.close
%>
</head>
<body>
<form name="myform" action="" method="get">
<select name="listbox1" id="listbox1" onChange="javascript: listboxchange(this.options[this.selectedIndex].value);">
<option value="">Please Select</option>
<%=ListBox1%>
</select>
<select name="listbox2">
<option value="">Please Select</option>
</select>
<input type="submit" name="submit" value="show values" />
</form>
</body>
</html>
Thanks for helping…
system
November 23, 2010, 7:42pm
8
that code is predominantly ASP code. you might get more help if you post it in an ASP and not javascript forum.
btw - language= “javascript” is deprecated. you should be using type=“text/javascript”