and you want to list them in that order? I guess you have a few options. this would work:
- dim firstHalfString, secondHalf
-
do until objRS.eof
-
firstHalfString = firstHalfString & "<option value=" & chr(34) &_
-
objRS("col1") & chr(34) & ">" & objRS("col1") & "</option>" & vbNewLine
-
secondHalf = secondHalf & "<option value=" & chr(34) & objRS("col2") &_
-
chr(34) & ">" & objRS("col2") & "</option>" & vbNewLine
-
objRS.moveNext
-
loop %>
-
<select name="myCombinedSelect">
-
<%=firstHalfString%>
-
<%=secondHalf%>
-
</select>
-
Jared
Hi Jared,
I was looking for same kind of code but not this code for one of my project problems.. What I have is..
One drop down box two list boxes..
Based on the drop down box value the sub categories of that value are displayed in the listbox(say listbox1)... Now i let user choose from my listbox1 a value and add it to second listbox value(say listbox2)
what i want is ..
if the drop down box has values say Countries..and listbox1 has provinces corresponding to the country chosen ... is user chooses two Provinces from one country and three provinces from another then the display on the third list box should be:
Country1 : Province1
Province2
Country2: Province 1
Province2
Province3
and so on... is it possible..??
the snippet of my code is :
<!-------- Drop Down box ------------>
<% SQL= "select * from dacategory"
set category= conn.execute(SQL)%>
<Select onchange="init();" name="category" style="width:auto">
<%Do While not Category.Eof%>
<%If UCase(Trim(LocCategory))=UCase(Trim(category("cate gory_id"))) then%>
<Option Value="<%=category("category_id")%>" selected><%=category("category")%></Option>
<%else%>
<Option Value="<%=category("category_id")%>" ><%=category("category")%></Option>
<%End If%>
<% category.MoveNext%>
<%Loop%>
</Select>
<% category.close
set category=nothing%>
<!-------- List Box1 ------------->
<% SQL="select * from da_static_flds where category_id="&loccategory
set flds= conn.execute(SQL)%>
<select name="fields" multiple="multiple" style="width:auto" size="9" >
<%do while not flds.eof%>
<Option Value="<%=flds("fld_id")%>"><%=flds("field_name")% ></Option>
<% flds.movenext
loop
flds.close
set flds=nothing
%>
</select>
<!------------- Buttons to add and remove ---------->
<input onclick="addtolist();" type="button" name="add" value=" Add >>" /><br /><input name="remove" onclick="removefromlist();" type="button" value="<< Remove" />
<!------------ Listbox2 -------------------->
<select name="selected" multiple="multiple" style="width:inherit" size="9" >
<option value=""></option>
</select>
<input type="hidden" name="temp" value="" />
<input type="hidden" name="Action" value="0" />
</form>
<!----------------- Javascript for functions ------------>
<script language="javascript">
function addtolist()
{
var Flds=document.frm.fields;
var SelFlds=document.frm.selected;
for (i=0;i<Flds.length;i++)
{
if (Flds[i].selected==true)
{
var chk=0;
var tmp="";
for (j=0;j<SelFlds.length;j++) {
if(SelFlds[j].text==Flds[i].text)
{ chk=1;}}
if(chk==0)
{
SelFlds.options[SelFlds.length]=new Option(Flds[i].text);
alert(SelFlds.length)
SelFlds.options[SelFlds.length-1].value = Flds[i].value;
}
fillTmp();
}
}
}
function fillTmp() {
var SelFlds = document.frm.selected;
var tmp = "";
for (j=0;j<SelFlds.length;j++) {
if (tmp=="") {
tmp = SelFlds[j].value;
}
else {
tmp = tmp+","+SelFlds[j].value;
}
}
document.frm.temp.value = tmp;
}
function removeFromList() {
var SelFlds = document.frm.selected;
for (i=0;i<SelFlds.length;i++) {
if (SelFlds[i].selected==true) {
SelFlds[i]=null;
i=0;
}
}
fillTmp();
}
</script>
Thanks
Cognac