Solved

HTML:  Word Wrap <SELECT> <OPTION>

Posted on 2009-04-01
8
7,609 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
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
 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

687 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