vennlou
06-04-2003, 05:51 AM
I need help in creating an edit page which will enable the user to change the selected record. I have not problem in being able to edit a record. The problem I do have is that on the page is a number of drop downs.
I need these drop downs to show all the options as well as default to the record the users wishes to change.
I have been able to do this on the first drop down, but the other drop downs default to the first option in the list.
I would be gratful for any help in this problem.
<!-- #include file="adovbs.inc" -->
<%
Dim CONN_STRING
Dim CONN_USER
Dim CONN_PASS
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\intranet\thomtest\design\elecd\darwin\darwin_v100_rc1.mdb"
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim objPagingConn
Dim objPagingRS
Dim iRecordsShown
Dim I
iPageSize = 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = " SELECT TBL_Master_Defect_Details.Defect_Details_PK_ID, TBL_Master_Defect_Details.Defect_Title, TBL_Master_Defect_Details.Defect_Description, TBL_Master_Defect_Details.Defect_Comments, " & _
" TBL_Master_Defect_Details.Defect_SW_Ver_Found, TBL_Master_Defect_Details.Defect_Date_Discovered, TBL_Master_Defect_Details.Defect_HW_Serial_Number, TBL_Master_Defect_Details.Defect_Previous_Ref, " & _
" TBL_Master_Defect_Details.Defect_Status_ID, TBL_Defect_Status.Status, TBL_Master_Defect_Details.Defect_Genre_ID, TBL_Defect_Genre.Genre, TBL_Master_Defect_Details.Defect_Frequency_ID, " & _
" TBL_Defect_Frequency.Frequency, TBL_Master_Defect_Details.Defect_Severity_ID, TBL_Defect_Severity.Severity, TBL_Master_Defect_Details.Defect_Priority_Cal, TBL_Master_Defect_Details.Personnel_ID, " & _
" TBL_Personnel.Personnel, TBL_Master_Defect_Details.Model_Name_ID, TBL_Model_Name.Model_Name, TBL_Master_Defect_Details.Project_Name_ID, TBL_Project_Name.Project_Name " & _
" FROM TBL_Project_Name INNER JOIN (TBL_Personnel INNER JOIN (TBL_Model_Name INNER JOIN (TBL_Defect_Status INNER JOIN (TBL_Defect_Severity INNER JOIN (TBL_Defect_Genre INNER JOIN (TBL_Defect_Frequency INNER JOIN TBL_Master_Defect_Details " & _
" ON TBL_Defect_Frequency.Defect_Frequency_ID = TBL_Master_Defect_Details.Defect_Frequency_ID) ON TBL_Defect_Genre.Defect_Genre_ID = TBL_Master_Defect_Details.Defect_Genre_ID) " & _
" ON TBL_Defect_Severity.Defect_Severity_ID = TBL_Master_Defect_Details.Defect_Severity_ID) ON TBL_Defect_Status.Defect_Status_ID = TBL_Master_Defect_Details.Defect_Status_ID) ON TBL_Model_Name.Model_Name_ID = TBL_Master_Defect_Details.Model_Name_ID) " & _
" ON TBL_Personnel.Personnel_ID = TBL_Master_Defect_Details.Personnel_ID) ON TBL_Project_Name.Project_Name_ID = TBL_Master_Defect_Details.Project_Name_ID "
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "No records found!"
Else
objPagingRS.AbsolutePage = iPageCurrent
%>
<p> <font size="+1">Page <strong><%= iPageCurrent %></strong> of <strong><%= iPageCount %></strong></font> </p>
<form method=post>
<input type="hidden" name="ID" value="<%=objPagingRS("defect_details_pk_id")%>">
<input type="hidden" name="personnel_id" value="<%=objPagingRS("personnel_id")%>">
Title <input type="text" name="Defect_title" size="40" value="<%=objPagingRS("defect_title")%>"><br>
Description <textarea name="defect_description" cols="40"><%=objPagingRS("defect_description")%></textarea><br>
Comments <textarea name="defect_comments" cols="40"><%=objPagingRS("defect_comments")%></textarea><br>
Software Version <input type="text" name="defect_sw_ver_found" size="10" value="<%=objPagingRS("defect_sw_ver_found")%>"><br>
Hardware ID <input type="text" name="defect_HW_Serial_Number" size="10" value="<%=objPagingRS("defect_HW_Serial_Number")%>"><br>
Previous Reference <input type="text" name="defect_previous_ref" size="10" value="<%=objPagingRS("defect_previous_ref")%>"><br>
Date <input type="text" name="defect_date_discovered" size="10" value="<%=objPagingRS("defect_date_discovered")%>"><br>
Severity <input type="text" name="sev_id" size="10" value="<%=objPagingRS("severity")%>"><br>
Genre <input type="text" name="genre_id" size="10" value="<%=objPagingRS("genre")%>"><br>
Tester <select name="personnel_id">
<%
while not objPagingRS.eof
if Cint(personnel_id) = objPagingRS("personnel_id") then
Selected = "selected"
End IF
%>
<option <%=Selected%> value="<%=objPagingRS("personnel_id")%>"><%=objPagingRS("personnel")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
Wend
%>
</select>
<br>
Severity <select name="defect_severity_id">
<%
objPagingRS.movefirst
objPagingRS.movenext
while not objPagingRS.eof
RESPONSE.WRITE "SEVERITYFROM RS" & objPagingRS("DEFECT_SEVERITY_ID")
RESPONSE.WRITE "SEVERITY TEST" & DEFECT_SEVERITY_ID
if Cint(defect_severity_id) = CINT(objPagingRS("defect_severity_id")) then
RESPONSE.WRITE("HOORAY")
Selected = "selected"
End If
%>
<option <%=Selected%> value="<%=objPagingRS("defect_severity_id")%>"><%=objPagingRS("severity")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
wend
%>
</select>
<br>
Genre <select name="defect_genre_id">
<%
objPagingRS.movefirst
objPagingRS.movenext
while not objPagingRS.eof
if Cint(defect_genre_id) = objPagingRS("defect_genre_id") then
Selected = "selected"
End If
%>
<option <%=Selected%> value="<%=objPagingRS("defect_genre_id")%>"><%=objPagingRS("genre")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
wend
%>
</select>
<br>
<input type="submit" value="Update">
</form>
<%
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
If iPageCurrent > 1 Then
%>
<a href="db_paging.asp?page=<%= iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
Prev]</a>
<%
End If
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a href="db_paging.asp?page=<%= I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I
If iPageCurrent < iPageCount Then
%>
<a href="db_paging.asp?page=<%= iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[Next
>>]</a>
<%
End If
end if
%>
I need these drop downs to show all the options as well as default to the record the users wishes to change.
I have been able to do this on the first drop down, but the other drop downs default to the first option in the list.
I would be gratful for any help in this problem.
<!-- #include file="adovbs.inc" -->
<%
Dim CONN_STRING
Dim CONN_USER
Dim CONN_PASS
CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\intranet\thomtest\design\elecd\darwin\darwin_v100_rc1.mdb"
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim strOrderBy
Dim strSQL
Dim objPagingConn
Dim objPagingRS
Dim iRecordsShown
Dim I
iPageSize = 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
strSQL = " SELECT TBL_Master_Defect_Details.Defect_Details_PK_ID, TBL_Master_Defect_Details.Defect_Title, TBL_Master_Defect_Details.Defect_Description, TBL_Master_Defect_Details.Defect_Comments, " & _
" TBL_Master_Defect_Details.Defect_SW_Ver_Found, TBL_Master_Defect_Details.Defect_Date_Discovered, TBL_Master_Defect_Details.Defect_HW_Serial_Number, TBL_Master_Defect_Details.Defect_Previous_Ref, " & _
" TBL_Master_Defect_Details.Defect_Status_ID, TBL_Defect_Status.Status, TBL_Master_Defect_Details.Defect_Genre_ID, TBL_Defect_Genre.Genre, TBL_Master_Defect_Details.Defect_Frequency_ID, " & _
" TBL_Defect_Frequency.Frequency, TBL_Master_Defect_Details.Defect_Severity_ID, TBL_Defect_Severity.Severity, TBL_Master_Defect_Details.Defect_Priority_Cal, TBL_Master_Defect_Details.Personnel_ID, " & _
" TBL_Personnel.Personnel, TBL_Master_Defect_Details.Model_Name_ID, TBL_Model_Name.Model_Name, TBL_Master_Defect_Details.Project_Name_ID, TBL_Project_Name.Project_Name " & _
" FROM TBL_Project_Name INNER JOIN (TBL_Personnel INNER JOIN (TBL_Model_Name INNER JOIN (TBL_Defect_Status INNER JOIN (TBL_Defect_Severity INNER JOIN (TBL_Defect_Genre INNER JOIN (TBL_Defect_Frequency INNER JOIN TBL_Master_Defect_Details " & _
" ON TBL_Defect_Frequency.Defect_Frequency_ID = TBL_Master_Defect_Details.Defect_Frequency_ID) ON TBL_Defect_Genre.Defect_Genre_ID = TBL_Master_Defect_Details.Defect_Genre_ID) " & _
" ON TBL_Defect_Severity.Defect_Severity_ID = TBL_Master_Defect_Details.Defect_Severity_ID) ON TBL_Defect_Status.Defect_Status_ID = TBL_Master_Defect_Details.Defect_Status_ID) ON TBL_Model_Name.Model_Name_ID = TBL_Master_Defect_Details.Model_Name_ID) " & _
" ON TBL_Personnel.Personnel_ID = TBL_Master_Defect_Details.Personnel_ID) ON TBL_Project_Name.Project_Name_ID = TBL_Master_Defect_Details.Project_Name_ID "
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize
objPagingRS.CacheSize = iPageSize
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly, adCmdText
iPageCount = objPagingRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write "No records found!"
Else
objPagingRS.AbsolutePage = iPageCurrent
%>
<p> <font size="+1">Page <strong><%= iPageCurrent %></strong> of <strong><%= iPageCount %></strong></font> </p>
<form method=post>
<input type="hidden" name="ID" value="<%=objPagingRS("defect_details_pk_id")%>">
<input type="hidden" name="personnel_id" value="<%=objPagingRS("personnel_id")%>">
Title <input type="text" name="Defect_title" size="40" value="<%=objPagingRS("defect_title")%>"><br>
Description <textarea name="defect_description" cols="40"><%=objPagingRS("defect_description")%></textarea><br>
Comments <textarea name="defect_comments" cols="40"><%=objPagingRS("defect_comments")%></textarea><br>
Software Version <input type="text" name="defect_sw_ver_found" size="10" value="<%=objPagingRS("defect_sw_ver_found")%>"><br>
Hardware ID <input type="text" name="defect_HW_Serial_Number" size="10" value="<%=objPagingRS("defect_HW_Serial_Number")%>"><br>
Previous Reference <input type="text" name="defect_previous_ref" size="10" value="<%=objPagingRS("defect_previous_ref")%>"><br>
Date <input type="text" name="defect_date_discovered" size="10" value="<%=objPagingRS("defect_date_discovered")%>"><br>
Severity <input type="text" name="sev_id" size="10" value="<%=objPagingRS("severity")%>"><br>
Genre <input type="text" name="genre_id" size="10" value="<%=objPagingRS("genre")%>"><br>
Tester <select name="personnel_id">
<%
while not objPagingRS.eof
if Cint(personnel_id) = objPagingRS("personnel_id") then
Selected = "selected"
End IF
%>
<option <%=Selected%> value="<%=objPagingRS("personnel_id")%>"><%=objPagingRS("personnel")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
Wend
%>
</select>
<br>
Severity <select name="defect_severity_id">
<%
objPagingRS.movefirst
objPagingRS.movenext
while not objPagingRS.eof
RESPONSE.WRITE "SEVERITYFROM RS" & objPagingRS("DEFECT_SEVERITY_ID")
RESPONSE.WRITE "SEVERITY TEST" & DEFECT_SEVERITY_ID
if Cint(defect_severity_id) = CINT(objPagingRS("defect_severity_id")) then
RESPONSE.WRITE("HOORAY")
Selected = "selected"
End If
%>
<option <%=Selected%> value="<%=objPagingRS("defect_severity_id")%>"><%=objPagingRS("severity")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
wend
%>
</select>
<br>
Genre <select name="defect_genre_id">
<%
objPagingRS.movefirst
objPagingRS.movenext
while not objPagingRS.eof
if Cint(defect_genre_id) = objPagingRS("defect_genre_id") then
Selected = "selected"
End If
%>
<option <%=Selected%> value="<%=objPagingRS("defect_genre_id")%>"><%=objPagingRS("genre")%>
</option>
<%objPagingRS.MoveNext
Selected = ""
wend
%>
</select>
<br>
<input type="submit" value="Update">
</form>
<%
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing
If iPageCurrent > 1 Then
%>
<a href="db_paging.asp?page=<%= iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
Prev]</a>
<%
End If
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a href="db_paging.asp?page=<%= I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I
If iPageCurrent < iPageCount Then
%>
<a href="db_paging.asp?page=<%= iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[Next
>>]</a>
<%
End If
end if
%>