Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

is there a way to word wrap in a drop down list?  RSS feed

 
rich werth
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I'm filling a drop down list with info from a database. The info from the database is pretty long. Each item expands the drop down list across the screen. I was wondering if there was a way to 'word wrap' the information so that the dropdown list didn't expand across the whole screen.
Here is the code i have.
<select name="var1">
<%
rs.first();
while (rs.next()) {
String var1 = rs.getString(1);
%>
<option value=<%=var1%>><%=var1%>
<% } //end loop for var1%>
</select>
Thanks for your help!!
 
Zkr Ryz
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could do something like this:
<select name="var1">
<%
rs.first();
String var1 = "";
while (rs.next()) {
var1 = rs.getString(1);
%>
<option value=<%=var1%>><%=var1.substring(0,10)%>...
<%}%>
</select>
Even better you could do a wordWrap merthod to prevent substring index exceptions and to avoid cutting a word in the middle.
Hope it helps
 
Jolly Jumper
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Zkr Ryz:
You could do something like this:
<select name="var1">
<%
rs.first();
String var1 = "";
while (rs.next()) {
var1 = rs.getString(1);
%>
<option value=<%=var1%>><%=var1.substring(0,10)%>...
<%}%>
</select>
Even better you could do a wordWrap merthod to prevent substring index exceptions and to avoid cutting a word in the middle.
Hope it helps

I don't think cutting the text for Select values is a good solution 'cause the developer may need the full text from select object.
Use Javascript instead will resolve this. Do not put server jsp code between <select> and </select> tags, move it to page <header>, for each record from result set, out.print JScript code to assign Option for select field,
out.print("document.forms[0].var1.options[i]= new Option(....)");
It works well on both IE5 and Netscape 4.7
For IE5, you may simply set the style for select element.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!