View Full Version : i have 1 drop down list, and 2 combo box lists....
NinjaTurtle
12-14-2002, 04:52 AM
dear,
i have 1 drop down list, and 2 combo box lists....
at the time i select 1 category from the drop down list, i will need to retrieve some data from database and list all the records into the combo box list, if i change the category from the drop down list it will change the new record and list into the combobox list, but without the page refresh.
how to do that?
Example:
2 tables in database:
Subject & Student.
the Subject will display on the select drop down list,
when user select one of the subject, the Student that related to the particular subject will display on the combobox list.
but without refresh page when user select the subject from the list.
angiras
12-14-2002, 07:48 AM
without the page refresh cannot be , you have to go server side and comme back
if you really want no refresh you can write a javascript with two drop down list from your database , then you will have your 2 tables client side, of course you have to rewrite th ejavascript it each time when a new studient is inserted or update into your database
it is the solution I have for many groups of dropdown
something like:
Public Function EcrireJS() As String
Try
If File.Exists(Path:=CheminVerif) Then
File.Delete(Path:=CheminVerif)
End If
Catch ex As Exception
End Try
Dim fs As New FileStream(CheminVerif, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
Dim sw As New StreamWriter(fs, System.Text.Encoding.GetEncoding(1252))
k = ListeTableID.Count - 1
With sw
.WriteLine("function " + Fichier + "(quoi, sel)")
.WriteLine("{")
.WriteLine("var quel = sel.options[sel.selectedIndex].value;")
.WriteLine("var i, quant;")
.WriteLine("quoi.selectedIndex = 0;")
.WriteLine("quoi.length = 0;")
.WriteLine("if (quel != 'nothing')")
.WriteLine("{")
.WriteLine("quant = " + TableNom + "[quel].length;")
.WriteLine("quoi.length = quant;")
.WriteLine("for(i=0;i<" + TableNom + "[quel].length;i++)")
.WriteLine("{")
.WriteLine("quoi.options[i] = new Option(" + TableNom + "[quel][i][1]," + TableNom + "[quel][i][0]);")
.WriteLine("}")
.WriteLine("quoi.selectedIndex = 0;")
.WriteLine("}")
.WriteLine("}")
.WriteLine("")
.WriteLine(_Interligne + " (0)")
.WriteLine("")
.WriteLine(TableNom + " = new Array();")
.WriteLine(TableNom + "['" + Liste1 + "'] = new Array();")
.WriteLine(TableNom + "['" + Liste1 + "'][0] = new Array(2);")
.WriteLine(TableNom + "['" + Liste1 + "'][0][0] = 0;")
.WriteLine(TableNom + "['" + Liste1 + "'][0][1] = '" + Liste2 + "';")
.WriteLine("")
.WriteLine(_Interligne + " (0)")
.WriteLine("")
.WriteLine(TableNom + "['0'] = new Array();")
.WriteLine(TableNom + "['0'][0] = new Array(2);")
.WriteLine(TableNom + "['0'][0][0] = 1 ;")
.WriteLine(TableNom + "['0'][0][1] = '" + Liste2 + "';")
For i = 0 To k
.WriteLine("")
.WriteLine(_Interligne + " (" + (i + 1).ToString + ")")
.WriteLine("")
.WriteLine(TableNom + "['" + (i + 1).ToString + "'] = new Array();")
.WriteLine("")
Try
mListe = New Listes()
With mListe
.AjoutTitre = False
.ListeTable = TableListe
.ListeType = 1
.Param = True
.ParamVal = (i + 1).ToString 'ListeTableID(i + 1)
End With
Catch ex As Exception
With sw
.Write(ex.Message + " 100")
.Flush()
.Close()
End With
Exit Function
End Try
For j = 0 To mListe.GenereListe.Count - 1
.WriteLine(TableNom + "['" + (i + 1).ToString + "'][" + j.ToString + "] = new Array(2);")
.WriteLine(TableNom + "['" + (i + 1).ToString + "'][" + j.ToString + "][0] = " + Replace(mListe.GenereListe.GetKey(j).ToString, "'", _JsReplace) + ";")
.WriteLine(TableNom + "['" + (i + 1).ToString + "'][" + j.ToString + "][1] = '" + Replace(mListe.GenereListe.GetByIndex(j).ToString, "'", _JsReplace) + "';")
Next
Next
.WriteLine(_Interligne)
.WriteLine("")
.WriteLine("//code du 1° select = .Attributes.Add(""onchange"", """ + Fichier + "(this.form.dd_" + Fichier.ToLower + ", this);"")")
.WriteLine("")
.WriteLine("//<select class=""Liste60"" id=""dd_" + Fichier.ToLower + """ tabIndex="" runat=""server"" Rows=""4"">")
.WriteLine("//<option value=""0"" selected>" + Liste2 + "</option>")
.WriteLine("//</select>")
.Flush()
.Close()
End With
fs.Close()
End Function
datas are coming from my database
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.