scouse
08-04-2005, 07:24 AM
Hi,
I've managed to get this working, but I just want to check if there is a better, more efficient way of doing this as it seems a little bit long winded for what I'm trying to do.
Basically, I've got a select box for a list of cities which is populated from a database. However, I want the data that is retrieved to be ordered into different sub groups.
For example,
my database has the following fields:
CITY_ID, CITY_VALUE, CITY_OPTION, CITY_AREA
and some example data
1, LIV, LIVERPOOL, ENGLAND
2, CAR, CARDIFF, WALES
3, MAN, MANCHESTER, ENGLAND
4, GLA, GLASGOW, SCOTLAND
5, LON, LONDON, ENGLAND
6, SWA, SWANSEA, WALES
When populating the select box I want it to end up like this:
<select Name='CITY'>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>ENGLAND</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='LIV'>LIVERPOOL</OPTION>
<OPTION value='MAN'>MANCHESTER</OPTION>
<OPTION value='LON'>LONDON</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>WALES</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='CAR>CARDIFF</OPTION>
<OPTION value='SWA'>SWANSEA</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>SCOTLAND</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='GLA'>GLASGOW</OPTION>
</SELECT>
At the moment I'm creating a different recordset for each area. E.g
strENG ="Select * from city WHERE CITY_AREA='ENGLAND'"
Set engRS = objConn.Execute(strENG)
.
.
put into select box
strWAL ="Select * from city WHERE CITY_AREA='WALES'"
Set walRS = objConn.Execute(strWAL)
.
.
add into select box
.
.
and so on!
This all works fine, but I can't help thinking it isn't the most efficient way to do it. Would there be a simpilar way of putting all the data into one recordset and then putting each record into the relevent sub group as its populating the select box?
Sorry for the long post, but I couldn't explain it any easier :rolleyes:
Thanks
Phil
I've managed to get this working, but I just want to check if there is a better, more efficient way of doing this as it seems a little bit long winded for what I'm trying to do.
Basically, I've got a select box for a list of cities which is populated from a database. However, I want the data that is retrieved to be ordered into different sub groups.
For example,
my database has the following fields:
CITY_ID, CITY_VALUE, CITY_OPTION, CITY_AREA
and some example data
1, LIV, LIVERPOOL, ENGLAND
2, CAR, CARDIFF, WALES
3, MAN, MANCHESTER, ENGLAND
4, GLA, GLASGOW, SCOTLAND
5, LON, LONDON, ENGLAND
6, SWA, SWANSEA, WALES
When populating the select box I want it to end up like this:
<select Name='CITY'>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>ENGLAND</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='LIV'>LIVERPOOL</OPTION>
<OPTION value='MAN'>MANCHESTER</OPTION>
<OPTION value='LON'>LONDON</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>WALES</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='CAR>CARDIFF</OPTION>
<OPTION value='SWA'>SWANSEA</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='javascript:void(0);'>SCOTLAND</OPTION>
<OPTION value='javascript:void(0);'>--------------</OPTION>
<OPTION value='GLA'>GLASGOW</OPTION>
</SELECT>
At the moment I'm creating a different recordset for each area. E.g
strENG ="Select * from city WHERE CITY_AREA='ENGLAND'"
Set engRS = objConn.Execute(strENG)
.
.
put into select box
strWAL ="Select * from city WHERE CITY_AREA='WALES'"
Set walRS = objConn.Execute(strWAL)
.
.
add into select box
.
.
and so on!
This all works fine, but I can't help thinking it isn't the most efficient way to do it. Would there be a simpilar way of putting all the data into one recordset and then putting each record into the relevent sub group as its populating the select box?
Sorry for the long post, but I couldn't explain it any easier :rolleyes:
Thanks
Phil