Solved

HTML:  Word Wrap <SELECT> <OPTION>

Posted on 2009-04-01
8
6,771 Views
Last Modified: 2013-11-19
Hi All,


Is it possible to word wrap the selection options in HTML?

I want the use to choose between three sentenses, but they are pretty long, so would like to word wrap them.


0
Comment
Question by:detox1978
8 Comments
 
LVL 13

Expert Comment

by:qwerty021600
ID: 24038256
You can define word wrap in css and call that class in Select option. It is possible.
0
 
LVL 2

Author Comment

by:detox1978
ID: 24038275
can you provide a sample as i can't get that to work
0
 
LVL 11

Expert Comment

by:level9wizard
ID: 24041671
<!-- html -->
<select name="mySelect">
    <option class="optionWrap"> ...</option>
</select>

/* css */
.optionWrap
{
    width: 100px;
}

Set the width should do it.
0
 
LVL 2

Author Comment

by:detox1978
ID: 24044026
I want to word wrap (put one option on several lines).

The code you present, doesn't do this.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 13

Expert Comment

by:qwerty021600
ID: 24046843
You need to create a custom control for this. Either a Telerik control or through Ajax ToolKit.

Refer this:
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/
0
 
LVL 2

Author Comment

by:detox1978
ID: 24051969
can you give a little more information?
0
 
LVL 12

Accepted Solution

by:
Chad Haney earned 500 total points
ID: 24398658
With the select option this is not possible.  As Identified by qwerty I would recomend an Ajax control, or create a custom control utilizing css to hide the options until the form button is clicked, then when the option is selected it populates a hidden input field with the select value, and you populate a readonly input box (or just a span) with the text value.

here is a mock up:
//script
function showValues(){
     document.getElementById('selectOptions').style.display="block";
}
function setValue(theValue, theText){
     document.getElementById('selectValue').value=theValue;
     document.getElementById('displayValue').value=theText;
     document.getElementById('selectOptions').style.display="none";
}

//code
<form>
<input type="hidden" name="selectValue" id="selectValue"/>
<input type="text" readonly="readonly" onclick="showValues()" id="displayValue"/>
<ul id="selectOptions" style="display:none">
<li><a href="javascript:setValue('[SelectValue]', "Item 1");">Item 1</a></li>
<li><a href="javascript:setValue('[SelectValue]', "Item 2");">Item 2</a></li>
</ul>
</form>
0
 
LVL 2

Author Comment

by:detox1978
ID: 24400505
I guess i could use CSS to make a combo looking box that does this.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML page and JavaScript 2 52
Best Practice CSS floating images 2 16
CSS grid style change 2 14
CSS measurement 10 14
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now