Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Columns in Listbox?

Status
Not open for further replies.

DVDGirl

Programmer
Mar 29, 2001
42
US
Hi -
Is there a way to create columns in a listbox? I want to create a listbox that has columns like those in Access.

I think one way to tackle this may be with datagrids, but I'm not sure how to do this in classic ASP.

Can anyone give me suggestions on how to do this? Any help is greatly appreciated. Thank you!

-DVD Girl
 
Instead of using a list box, you could use a div tag with a table inside then you could set the height width of the div tag and make it scrollable. Thus making it look like a list box.

Ex-------------------------------------------------------

<DIV style=&quot;width:200;height:50;overflow:auto;&quot;>
<Table border=1 >
<TR><TD>Column 1</TD><TD>Column 2</TD><TD>Column 3</TD></TR>
<TR><TD>Column 1</TD><TD>Column 2</TD><TD>Column 3</TD></TR>
<TR><TD>Column 1</TD><TD>Column 2</TD><TD>Column 3</TD></TR>
<TR><TD>Column 1</TD><TD>Column 2</TD><TD>Column 3</TD></TR>
<Table>
</DIV>
----------------------------------------------------------- &quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
MrGreed -
Thanks for your prompt response! I can use your method for one of my listboxes, however, in another instance, I would have to select a row, thus selecting a record, then remove or modify the selected record.

Any other recommendations? Thanks again!

-DVD Girl
 
Your getting more into the &quot;Data Grid&quot; realm, with your 2nd request. But, you can still implement your above features. You would have to create a script that would highlight a row in the table that the user clicks on and then, you could let the user modify the data, by accessing each rows cells.

The above is a bit more work but it can be done. We are not talking about ListBoxes anymore, we have really have gone outside that realm. &quot;did you just say Minkey?, yes that's what I said.&quot;

MrGreed
 
How about just displayinmg the row in each option but set the value equal to the key from the table? This way you can re-access the exact row the person selected:
Pretend we have a table called Favorites
Code:
<%
Dim sql_fave, rs_fave
sql_fave = &quot;SELECT * FROM Favorites&quot;
'execute SQL here into rs_fave

Response.Write &quot;<select name='selFave'>&quot;
rs_fave.MoveFirst
Do Until rs_fave.EOF
  Response.Write &quot;<option value='&quot; & rs_fave(&quot;favorite_id&quot;) & &quot;'>&quot; & rs_fave(&quot;fave_color&quot;) & &quot; | &quot; & rs_fave(&quot;fave_food&quot;) & &quot;</option>&quot;
   rs_fave.MoveNext
Loop
Response.Write &quot;</select>&quot;
%>
This way you have the key for the recoprd they choose in the value of the selected index. If you do not want them to have to go to the next page to see what they selected you could try and store the data in javascript arrays and pull it back out again based on the value (id) of the selected option. It would work similar to the select boxes where you make a selection from the first and the second autofills. Or you could just let them submit to the next page and SLEECT again from the database for the ID:
Code:
'Second page for favorites
Dim sql_fave, rs_fave
sql_fave = &quot;SELECT * FROM Favorites WHERE favorite_id = &quot;&Request.Form(&quot;selFave&quot;)
'execute and then display info in editable inputs

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top