Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SelectName

Status
Not open for further replies.

aladin1973

Programmer
Aug 22, 2001
3
FR
Hello everybody !!

Just one question : How can I integrate data of ACCESS Database in a selectName Combobox in VBscript or Javascript ?

Thanks a lot.
 
Like this:
Code:
<select size=&quot;7&quot; name=&quot;foo&quot;><%
   Dim db,rs
   Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
   Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

   db.Open &quot;DBQ=&quot; & Server.MapPath(&quot;database.mdb&quot;) & &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;   
   Set rs = db.Execute(&quot;select fooid,fooname from footable&quot;)

   Do While Not rs.EOF
      response.write(&quot;<OPTION VALUE=&quot; & rs(&quot;fooID&quot;)  & &quot;>&quot; & rs(&quot;fooName&quot;) & &quot;</OPTION>&quot;)
      rs.MoveNext
   Loop
   rs.Close
   db.Close%>
</select>
Hope this helps,
Palooka
 
Ok, Thank you. So, I have integrated your code in my program, but it doesn't works yet as I would like : now, I would like to activate another one Combobox (of Messages) in fonction of the item that I select in the first Combobox. Please find here my code for you see that.

<td width=&quot;192&quot; height=&quot;80&quot; colspan=&quot;2&quot; rowspan=&quot;1&quot; valign=&quot;top&quot; align=&quot;left&quot; xpos=&quot;176&quot;><select name=&quot;selectName&quot; size=&quot;7&quot;>
<%
Dim db,rs
Set db = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
db.Open &quot;DBQ=&quot; & Server.MapPath(&quot;messages.mdb&quot;)& &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
Set rs = db.Execute(&quot;SELECT Nom_Afficheur from Table_Afficheurs&quot;)
Do while Not rs.EOF
Response.Write(&quot;<OPTION VALUE=&quot; & rs(&quot;Nom_Afficheur&quot;)& &quot;>&quot; & rs(&quot;Nom_Afficheur&quot;) & &quot;</OPTION>&quot;)
rs.MoveNext
Loop
rs.Close
db.Close %>
</select></td>
<td width=&quot;32&quot; height=&quot;80&quot;></td>
<td width=&quot;192&quot; height=&quot;80&quot; colspan=&quot;4&quot; rowspan=&quot;1&quot; valign=&quot;top&quot; align=&quot;left&quot; xpos=&quot;400&quot;><select name=&quot;selectNameMessages&quot; size=&quot;4&quot; multiple>
<%
Dim sSelect
sSelect = Request.Form(&quot;selectName&quot;)
Dim db2,rs2
Set db2 = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rs2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
db2.Open &quot;DBQ=&quot; & Server.MapPath(&quot;messages.mdb&quot;)& &quot;;Driver={Microsoft Access Driver (*.mdb)};&quot;
Set rs2 = db.Execute(&quot;SELECT Contenu_Message from Table_Afficheurs_Sélectionnés WHERE Nom_Afficheur = &quot; & SQLstr(sSelect))
Do while Not rs2.EOF
Response.Write(&quot;<OPTION VALUE=&quot; & rs2(&quot;Contenu_Message&quot;)& &quot;>&quot; & rs2(&quot;Contenu_Message&quot;) & &quot;</OPTION>&quot;)
rs2.MoveNext
Loop
rs.Close
db.Close
%>
</select></td>

Thanks you again.
Aladin1973
 
If I understand you correctly you have two combo boxes, and you would like the options in the second box to vary, based on the choice selected in the first box.

If that is the case, you could use the onChange Javascript event. See . I'm not sure if this is possible in VBScript.

Hope this helps,
Palooka
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top