![]() |
| |||||||
| Sponsored Links |
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
| Hi All, I have a search screen with allows many different searches and results. The results can be one or many records. After results are displayed I have an Edit button to edit the record(s). Well, the two fields Region / District go hand in hand. The code below works but what happens is...let's say I search for Region "Africa", I may get 10 records, well, let's say I want to change two of the records to a different Region (like "Canada"), I do see "Canada" in the list but when I select it, it doesn't update the District list....I will still see the districts for Africa, so I have to save my Region "Canada", then go search for "Canada" records and then I'll see the "Canada" districts and I can pick one. Is there a way to submit when a new Region is selected when in the edit mode on multiple records so it could update the District list? Hope this makes sense, let me know if you have any more questions and Thanks for any direction and help! Code: <TD>
<SELECT CLASS="clrBg" name="RegionName<%response.write(i)%>">
'onChange="frmSearch.action='EditAssetList4.asp';frmSearch.submit();"
<%
strSQL = "Select Distinct RegionName,RegionID from vwReg_Dist"
set rs2 = conn.execute(strSQL)
strRegionID = rs("RegionID")
response.write Space(16) & "<option value=""0"">Select Region</option>"
Do While Not rs2.EOF
response.write Space(16) & "<option value=""" & rs2("RegionID") & """"
If CStr(rs2("RegionID")) = CStr(strRegionID) Then
response.write " selected"
End If
response.write ">" & rs2("RegionName") & "</option>" & vbCrLf
rs2.MoveNext
Loop
%>
<% rs2.Close
set rs2 = Nothing
%>
</SELECT>
</TD>
<TD>
<SELECT CLASS="clrBg" name="District<%response.write(i)%>">
<%
strSQL2 = "Select Distinct Concatenate, DistrictID from vwReg_Dist where RegionID='" & strRegionID & "' Order by Concatenate"
set rs3 = conn.execute(strSQL2)
strRegionID = rs("RegionID")
strDistrictID = rs("DistrictID")
response.write Space(16) & "<option value=""0"">Select District</option>"
Do while not rs3.eof
response.write Space(16) & "<option value=""" & rs3("DistrictID") & """"
If CStr(rs3("DistrictID")) = CStr(strDistrictID) then
response.write " selected"
End If
response.write ">" & rs3("Concatenate") & "</option>" & vbCrLf
rs3.MoveNext
Loop
%>
<%
rs3.Close
set rs3 = Nothing
%>
</SELECT>
</TD>
|
| Sponsored Links |
|
#2
| ||||
| ||||
| You have been working on this for a while now, haven't you? I think you logic is wrong. Based on the code I see, I do not see where you define the recordset "rs". Also, why do you keep referencing the "rs" recordset? Why not store that value in a variable and close the connection? That would be much more efficient. Anways, I am not sure what you are trying to accomplish here? To clean up your code, I would suggest that you use subs to create your selects. For instance, like so: Code: Sub DistrictSelect(intID, intRegionID, intDistrictID)
strSQL = "SELECT DISTINCT Concatenate, DistrictID FROM vmReg_Dist WHERE RegionID = '" & strRegionID & "' ORDER BY Concatenate"
Set objRS = conn.Execute(strSQL)
response.write "<select name=""District" & intID & """ class=""clrBg"">" & vbCrLf
response.write "<option value="""">Select District</option>" & vbcrLf
Do While Not objRS.EOF
response.write "<option value=""" & objRS("DistrictID") & """"
If CStr(objRS("DistrictID")) = CStr(strDistrictID) Then
response.write " selected"
End If
response.write ">" & objRS("Concatenate") & "</option>" & vbCrLf
objRS.MoveNext
Loop
response.write "</select>" & vbCrLf
objRS.Close
Set objRS = Nothing
End Sub
Code: intRegionID = rs("RegionID")
intDistrictID = rs("DistrictID")
intID = 10
Code: <tr> <td><% Call DistrictSelect(intID, intRegionID, intDistrictID) %></td> </tr> |
|
#3
| ||||
| ||||
| Hi BLaaaaaaaaaarche, Yes, Ok, let me go and change it back. I had your suggestion before and it did work and make the code cleaner but still couldn't figure how to do an OnChange to update the district list only for the one record with multiple records on the screen. My screen looks similar to this: Region List --District List--Category List--Size List--Desc--more fields Africa Angola Hammer 8" 8" Hammer Africa Congo Hammer 6" 6" Hammer So if I want to change the second record Region to Canada, I can do so but the District list won't show Canada district, it still shows Africas districts. I'll come back once I change the code back and see how I can implement the OnChange or something similar to do this. Thank you |
|
#4
| ||||
| ||||
| It might help if you provide us with a sample of your DB and your full code as I have no idea what you are trying to accomplish. |
|
#5
| ||||
| ||||
| Due to inactivity of 14 days, this thread is deemed abandoned and is now closed. If this thread was marked as "Solved", the orginal poster may mark it as "Unsolved" via the Thread Tools menu, thus re-opening the thread. If this thread was not marked as "Solved", the original poster may re-open the thread via the Thread Tools menu. Regards, richyrich DeveloperBarn Forums Moderator |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|