Author |
Topic  |
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 04:39:52
|
Anybody can suggest me as to populate a dropdown list using the data fixed in a access database ??? I've this code for the dropdown list
If strRqMethod = "Topic" then
Response.Write " <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Kind of shift</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection2"" size=""1"" tabindex=""-1"" >" & vbNewLine & _
" <option value=""" & """>no value</option>" & vbNewLine & _
Response.Write " </select>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" </tr>" & vbNewLine
End If
but i want that the option value are the record saved in the database
Please help me, i'm getting crazy trying to solve this problem
bye stefano |
|
Carefree
Advanced Member
    
Philippines
4217 Posts |
Posted - 24 May 2004 : 05:10:56
|
quote:
If strRqMethod = "Topic" then
Response.Write " <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Kind of shift</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection2"" size=""1"" tabindex=""-1"" >" & vbNewLine & _
" <option value=""" & """>no value</option>" & vbNewLine & _
Response.Write " </select>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" </tr>" & vbNewLine
End If
but i want that the option value are the record saved in the database
Change this line to include the variable of the data:
" <option value=""" & (variable or field here) & """>no value</option>" & vbNewLine & _
|
 |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 05:35:17
|
i've almost solved :
Set objDC = Server.CreateObject("ADODB.Connection")
strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/NewElogBook/logbook/database/elogbook.mdb")
objDC.Open strConn
Set objRS = objDC.Execute("Select PROVA_gruppo FROM FORUM_PROVA")
Response.Write " <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Event:</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection1"" size=""1"" tabindex=""-1"" >" & vbNewLine
if NOT objRs.RecordCount = 0 then
Do While (Not objRs.EOF)
Response.Write " <option value=""" & """>"& PROVA_gruppo &"</option>" & vbNewLine
objRs.MoveNext
Loop
End If
Response.Write " </select>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" </tr>" & vbNewLine
objRs.Close
Set objRs = Nothing
objDC.Close
Set objDC = Nothing
Now i connect to the database and retrive the right data, but the problem is that i'm not able to put them in the dropdownlist (in the red line)
any suggest??
bye stefano |
Edited by - s80ts0465 on 24 May 2004 07:18:35 |
 |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 07:28:15
|
I've just tryed it, but the dropdown list is empty :-(( what to do?? |
 |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 07:43:25
|
i tryed and re-tryed and have found out this solution Response.Write " <option value=""" & PROVA_gruppo & """>" & objRS("PROVA_gruppo") & "</option>" & vbNewLine
On this way it populate the dropdown list with the right itmes
bye and thanks |
 |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 08:45:42
|
But now that i've found out how to populate the dropdown list i wanna create another a dependent dropdown list. So in a new dropdown list is shown some items is dipendence of the result of the first dropdown list. These are the 2 dropdown list:
Response.Write " <form name = ""Prova"" method=""post"" action=""post.asp"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Event:</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection1"" size=""1"" tabindex=""-1"" onchange=Prova.submit()>" & vbNewLine
Set objDC = Server.CreateObject("ADODB.Connection")
strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/NewElogBook/logbook/database/elogbook.mdb")
objDC.Open strConn
Set objRs = objDC.Execute("Select PROVA_gruppo FROM FORUM_PROVA")
if NOT objRs.RecordCount = 0 then
Do While (Not objRs.EOF)
Response.Write " <option value=""" & PROVA_gruppo & """>" & objRs("PROVA_gruppo") & "</option>" & vbNewLine
objRs.MoveNext
Loop
End If
Response.Write " </select>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" </form></tr>" & vbNewLine
objRs.Close
Set objRs = Nothing
objDC.Close
Set objDC = Nothing
Response.Write " <form name = ""Prova1"" method=""post"" action=""post.asp"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Event:</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection3"" size=""1"" tabindex=""-1"" >" & vbNewLine
Set objDC = Server.CreateObject("ADODB.Connection")
strConn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/NewElogBook/logbook/database/elogbook.mdb")
objDC.Open strConn
Set objRs = objDC.Execute("Select PROVA_fault FROM FORUM_PROVA WHERE PROVA_gruppo= "......")
if NOT objRs.RecordCount = 0 then
Do While (Not objRs.EOF)
Response.Write " <option value=""" & PROVA_fault & """>" & objRs("PROVA_fault") & "</option>" & vbNewLine
objRs.MoveNext
Loop
End If
Response.Write " </select>" & vbNewLine & _
" </font></td>" & vbNewLine & _
" </form></tr>" & vbNewLine
objRs.Close
Set objRs = Nothing
objDC.Close
Set objDC = Nothing
what i don't really understand is how to connect the two list. I'd like to use the code in red but i don't know how to set the condition. I've some doubts about the string onchange =Prova.submit() I've read somewhere that it should reload the page, but saving the item chosed ????
could you pleaseeeee help me
thanks stefano |
Edited by - s80ts0465 on 24 May 2004 09:18:13 |
 |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 09:15:40
|
Sorry but it doesn't wanna work It says Syntax error(missing operator) in the expression of the query 'PROVA_gruppo ='. What does it mean??? What to do??
about ur question, sorry i wrote it wrong, the second dropdown list get the value from PROVA_fault field
thanks a lot |
 |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 10:20:02
|
I'm sorry it doesn't work  U wrote strsql = "Select PROVA_fault FROM FORUM_PROVA WHERE PROVA_gruppo=" & Request.Form("Injection1") Set objRs = objDC.Execute(strSql)
i've tryed with and without the S but it doesn't work, and when i write the S too, i get the same message error of above
thanks a lot for ur help OneWayMule . do u still have some good ideas?? |
 |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 24 May 2004 : 17:44:03
|
Hey OneWayMule, any new idea??? i was thinking to create a function in javascript to give the items of the first droplist to the second one. What do u say about it??? |
 |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
s80ts0465
Junior Member
 
Italy
290 Posts |
Posted - 25 May 2004 : 03:50:17
|
Oh sorry i didn't wanna bug u or disturb, but i' in Italy so maybe we have different times sense. I've just tryed it. Now i don't get any error, but the second dropdown list isn't popultae Why??? Maybe caused the submit() function ???? How should it work???
Response.Write " <form name = ""Prova"" method=""post"" action=""post.asp"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """ noWrap vAlign=""top"" align=""right""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b>Event:</b></font></td>" & vbNewLine & _
" <td bgColor=""" & strPopUpTableColor & """><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & vbNewLine & _
" <select name=""Injection1"" size=""1"" tabindex=""-1"" onchange=Prova.submit()>" & vbNewLine
thanks |
Edited by - s80ts0465 on 25 May 2004 04:07:15 |
 |
|
OneWayMule
Dev. Team Member & Support Moderator
    
Austria
4969 Posts |
|
Topic  |
|