Sebastion
asked on
Combo Box wrap
Hello,
I was wondering if it was possible to wrap longer entries around in a combo box. When I was trying to find an answer to this problem on the net, I remember reading (not sure where) that it was only possible through CSS. Is this true, and if so, what do I need to do to implement it.
Any help would be appreciated
P.S, if its not possible through CSS, but is through some other method, I would like to hear them.
I was wondering if it was possible to wrap longer entries around in a combo box. When I was trying to find an answer to this problem on the net, I remember reading (not sure where) that it was only possible through CSS. Is this true, and if so, what do I need to do to implement it.
Any help would be appreciated
P.S, if its not possible through CSS, but is through some other method, I would like to hear them.
Hi,
The following is probably the best you can do with javascript -- not very pretty nor elegant, but reliable (works in NN4.7 -- which is the test imho):
<form name='a'>
<select name="b">
<option>aaaaaaaaaaaaabbbbb bbbbbbbbbc cccccccccc cccccc</op tion>
</select>
<script>
selObj = document.a.b
x = selObj.options[0].text;
if (x.length > 20)
{
selObj.options[0].text = x.substr(0,19)
selObj.options[1] = new Option(x.substr(20),selObj .options[0 ].value)
}
</script>
</body>
Vinny
The following is probably the best you can do with javascript -- not very pretty nor elegant, but reliable (works in NN4.7 -- which is the test imho):
<form name='a'>
<select name="b">
<option>aaaaaaaaaaaaabbbbb
</select>
<script>
selObj = document.a.b
x = selObj.options[0].text;
if (x.length > 20)
{
selObj.options[0].text = x.substr(0,19)
selObj.options[1] = new Option(x.substr(20),selObj
}
</script>
</body>
Vinny
ASKER
Hello,
I'm sorry guys, but that isn't what I was looking for. VincentPuglia, it looks like the code you have given would make a text two different options if it went over 20 characters, but that wouldn't be what I'm after.
I waited this long to reply in the hope that someone else would have possibly offered a solution, but since they haven't, I'm going to opt to close down the question soon. I close it down in about 3 days, in order to give you two some time to raise any objections (if you have any).
Thanks for your help anyway
I'm sorry guys, but that isn't what I was looking for. VincentPuglia, it looks like the code you have given would make a text two different options if it went over 20 characters, but that wouldn't be what I'm after.
I waited this long to reply in the hope that someone else would have possibly offered a solution, but since they haven't, I'm going to opt to close down the question soon. I close it down in about 3 days, in order to give you two some time to raise any objections (if you have any).
Thanks for your help anyway
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
VincentPuglia, again, wouldn't that create 4 different options instead of just wordwrapping 1? What I was after, was code that could word wrap a list box's options (similar to Microsoft Access, which word wraps but still makes it one option, so if the user highlights it, they highlight both rows).
Due to the fact that this page was due a few days ago, I have opted (for now) to use radio boxes, because (as been said) there seems to be no real solution.
>>would make a text two different options if it went over 20 characters
>>simply give both options the same values. in other words, treat them as one option
This would get confusing to a user (who may not be that computer literate), as some of the options would possible go over 30 words long and with about 5-6 options per question, they may or may not be able to tell where each question starts.
I agree that there may be work-arounds, and they may work in some scenarios with smaller options, however they would not work in my scenario nor with my intended audience.
I am willing to give you the points for this question as the answer might help other people who are experiencing similar problems to me (only on a smaller scale).
Due to the fact that this page was due a few days ago, I have opted (for now) to use radio boxes, because (as been said) there seems to be no real solution.
>>would make a text two different options if it went over 20 characters
>>simply give both options the same values. in other words, treat them as one option
This would get confusing to a user (who may not be that computer literate), as some of the options would possible go over 30 words long and with about 5-6 options per question, they may or may not be able to tell where each question starts.
I agree that there may be work-arounds, and they may work in some scenarios with smaller options, however they would not work in my scenario nor with my intended audience.
I am willing to give you the points for this question as the answer might help other people who are experiencing similar problems to me (only on a smaller scale).
You can't cause text to wrap in them in any current browser (short of trying to recreate the drop down menu using a heaft bunch of JavaScript which isn't reliable).
You might consider switching to radio buttons instead, you could place them inside a div with overflow, height and width set if you want to keep them in a small space..