473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Drop down

Hi,

I have a select list (drop down list) it has very long names like...
ababababababbabbabbababababbabbabbabaabbbaabbababb a
so by using style="width:100px" I have cut the size like this-
<select name="cars" style="width:100px"
But when user tries to access ths list I want the user to be able to
read the whole name.
So when user clicks on this select list I want to replace it with the
actual size.
I know this can be done using javascript.
but as Im new to Javascript Im not able to figure out the solution.
Please I need some help as I need to submit my project tomorrow.

Can someone give me an idea?

Thanks in advance,
Rashni

Dec 10 '05 #1
3 1241
I think the following code does something similar but Im not able to
understand anything as Im very new to this.
Basically I think the
function select_class is invoked when the user click
on a list (specified by ondblclick).

<script type="text/javascript">
function select_class(myform,myvar)
{
opt=myvar.options[myvar.selectedIndex].value;
txt=opt;
document.all.classt.value=txt;
document.all.entityt.value="0";
myform.submit();
}
</script>

<td><select name="classl" id="classl" size="9"
style="width:250px"
ondblclick="select_class(this.form,document.all.cl assl)">
<!FOREACH ics ic>
<option value ="<!REPLACE ic.getClassName()>">
<!REPLACE ic.getClassName()>
<!/FOREACH>
</select></td>

If someone could give me an idea I would really appreciate it.

Thanks,
rashni

Dec 10 '05 #2
rashni wrote:
Hi,

I have a select list (drop down list) it has very long names like...
ababababababbabbabbababababbabbabbabaabbbaabbababb a
so by using style="width:100px" I have cut the size like this-
<select name="cars" style="width:100px"
Better to use 'em' that pixels. Set the width of the select so that it
fits the longest option text (trial and error is probably the best
method). Then if the user has a different default text size, it will
still fit, and no JavaScript at all is required.

But when user tries to access ths list I want the user to be able to
read the whole name.
So when user clicks on this select list I want to replace it with the
actual size.
I know this can be done using javascript.
but as Im new to Javascript Im not able to figure out the solution.
That would be a rather awful piece of work - the select would change
width as different options were selected.

Please I need some help as I need to submit my project tomorrow.
Tomorrow? Where?


Can someone give me an idea?


Since its just a school project, and likely of zero practical value, try
looping through all the options and counting how many characters each
has to find the longest. Multiply the longest length by some factor
(0.75? trial and error will let you know) and set the width in em.

But I would never do that in a production system.
--
Rob
Dec 10 '05 #3
Hi Rob,

Thanks a lot for your help. I was able to create horizontal scroll bar
for my select list like this:

<!--<div align="center" id="comboContainer"
style="overflow:hidden;width:100px">-->

<div align="center" id="comboContainer"
style="overflow:scroll;width:200px">
<select size=5>
<option>a</option>
<option>This is a very long line that creates scroll
bar......</option>
<option>ahjjdfhasjhdfjkhaskjhfkhasdjkfh</option>
<option>afasd´kfléi9rui0jñasdfj</option>
<option>aasd asd</option>
<option>aasdasdasdsadasd</option>

</select>
</div>
Though this is not a very professional way of doing it, but its simple
and I got horizontal scroll bar!!

Thanks,
Rashni

Dec 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: PT | last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From that 3, 2 are dependant. I can choose one drop down, and the next drop down should display the dependant values of the first...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
1
by: pmelanso | last post by:
Hello, I have a drop down list which is dynatically loaded from a database and I have a second drop down list that is also dynatically loaded depending on what is selected in the first drop down...
7
by: callawayglfr | last post by:
I am building a database in access where I have a drop down box that relates to a text box, that part I have working but when someone selects information from the first drop down I need it to limit...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
3
by: penny111 | last post by:
Hi there, For my application, i need to have 3 drop down lists 1. drop down list of folder names 2. drop down list of documents in the folder selected 3. drop down list of instances of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.