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!

truncating values in a list/combo box.

Status
Not open for further replies.

scroce

MIS
Nov 30, 2000
780
US
I have a list box on an asp page that is populated by a field in a database that could be like 60 or 70 characters long.

The problem is that this creates a HUGE list box widthwise. I want to limit the screen display to 15 characters:

so what i did was this:
Code:
<select name=&quot;cboMemEntity&quot; width=&quot;10&quot;>
<option selected><%= rsMembers(&quot;Entity&quot;)%></option>

<%
do while not rsEntities.EOF 			     Response.Write &quot;<option>&quot;
Response.Write left(rsEntities(&quot;Entity&quot;),15)
Response.Write &quot;</option>&quot;
rsEntities.MoveNext 
Loop  
%>

</select>

which does in fact work to truncate the characters the populate the combo box.

The problem is that I am then trying to use the value of that combo box to update another field in that database, and the field only gets updated with that truncated value.
While I only want to show the first 15 characters in the combo box, I don't want the actual value that gets passed to be truncated to the first 15 - I need the full length.

How do I do this? Q: Why is my computer doing that?
A: Random Perversity of Inanimate
Objects
 
<% do while not rsEntities.EOF %>
<option value=&quot;<%=rsEntities(&quot;Entity&quot;)%>&quot;>
<%=left(rsEntities(&quot;Entity&quot;),15)%>
</option>
<%
rsEntities.MoveNext
Loop
%> Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
An additional option (just to provide another point of view) is to use CSS to set the width of the listbox:
Code:
<select name=&quot;cboMemEntity&quot; style=&quot;width:240px&quot;>
<option selected><%= rsMembers(&quot;Entity&quot;)%></option>
<%
do while not rsEntities.EOF
   Response.Write &quot;<option>&quot;
   Response.Write left(rsEntities(&quot;Entity&quot;),15)
   Response.Write &quot;</option>&quot;
   rsEntities.MoveNext 
Loop  
%>
</select>

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
very cool - thank you for your posts. They seem to work just fine. Q: Why is my computer doing that?
A: Random Perversity of Inanimate
Objects
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top