 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

August 24th, 2004, 10:00 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
Nested Loop Select Box Issue
Hello
This problem is a small one. I have been looking at it to long and am getting a little angry at my keyboard.
NOTE: Both queries are fine, there is no problem with the sql. The problem is when there is more than one result in the record set named 'getCatInfo'
OBJECTIVE:
1..produce a multiple select box containing the result of the second query (this is working fine)
2..make any values appear selected in the select area if any of the records in the record set named getCatInfo = any records in the record set named getInfo
mmmmm seems simple, I have done this many times without a problem. I have posted this as a problem because it runs fine with no errors and selects the record it's supposed to if there is only one result in the record set getCatInfo - however if there is more than on record in this record set it failes to make any values selected.
Thank you in advance
-------code start-------------
<tr>
<% sql = "SELECT calCategoryId FROM eventsCalendar WHERE eventId=" & request("eId") & ";"
set getCatInfo = conn.execute(sql)
sql = "SELECT id,folderName,parent FROM tblTreeMenu WHERE id IN(" & idsString & ") AND linkLocation <> 'default.asp' ORDER BY parent,folderName;"
set getInfo = conn.execute(sql) %>
<Td><select name="eventCategories" style=width:228; size="5" class="selectStyle" multiple>
<% do until getInfo.EoF %>
<option <% do until getCatInfo.EoF %>
<% if (getCatInfo(0) = getInfo(0)) then
response.write " selected "
end if
getCatInfo.moveNext
loop %> value="<%= getInfo(0) %>"><%= getInfo(1) %></option>
<% getInfo.moveNext
loop %>
</select></td>
-------code finish-------------
Wind is your friend
Matt
__________________
Wind is your friend
Matt
|
|

August 24th, 2004, 10:28 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
The problem may be that your second recordset has reached its eof.
For the first getInfo record you loop through the getCatInfo recordset untill it reaches eof.
Then you move to the next getInfo record.
But getCatINfo info is already EOF so the second loop will not occur the second time round.
You will need to use a cursor that allows you to return to the beginning of the recordset and loop through again using getCatInfo.moveFirst.
Alternatively you could load the getCatInfo rs into an array and loop through the array each time instead.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 24th, 2004, 10:45 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
rodmcleay
;; The problem may be that your second recordset has reached its eof.
good initial thought however this is not the case. hang on, wooow back there, you are spot on! Adding getCatInfo.moveFirst as illustrated below fixed the problem.
<% do until getInfo.EoF
getCatInfo.moveFirst%>
I was seriously about to break something. As I said I have done this sort of thing many times without issues, looks like I overlooked something that should have stuck out like westener in the streets of downtown Tokyo.
Thank you for your time and ATD
Wind is your friend
Matt
|
|

August 24th, 2004, 10:51 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
No Problem.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|

August 24th, 2004, 10:56 PM
|
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
|
|
I see you are from Perth. Some of the best kitesurfing conditions in the world, great stuff - say gidday to the 'fremantle doctor' for me.
Wind is your friend
Matt
|
|

August 24th, 2004, 11:02 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Yeah,
I'm not into it myself but you can see the masses all down the coast.
In the river too.
======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
|
|
 |