[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

sizing a select

Posted on 2002-04-05
9
Medium Priority
?
156 Views
Last Modified: 2010-04-09
I have this HTML code :

<TABLE>
 <TR>
  <TD BGCOLOR='#28A7F6' ALIGN='CENTER'>
    Aspect
  </TD>
</TR>
 <TR>
  <TD ALIGN='CENTER'>
   <select name=servicesPossibles1 size=3>
    <option>A</option>
    <option>B</option>
    <option>C</option>
   </select>
  </TD>
 </TR>
</TABLE>

(in fact, it's dynamic code).
It shows a title with a select. My problem is :
I don't want my select to be shorter than the title (the first cell of the table).
How do you set the width of the selct to be the one of the cell ?
0
Comment
Question by:seguret
[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
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:svd2002
ID: 6920490
1. Let the id of the cell be "c1" whose width is to be assigned to <SELECT>
2. Let the id of the <SELECT> be "s1"

Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
     function f()
     {
          s1.style.width = c1.clientWidth;
     }
//-->

This function can be called at the onLoad event of the <BODY>
0
 
LVL 2

Expert Comment

by:svd2002
ID: 6920494
1. Let the id of the cell be "c1" whose width is to be assigned to <SELECT>
2. Let the id of the <SELECT> be "s1"

Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
     function f()
     {
          s1.style.width = c1.clientWidth;
     }
//-->

This function can be called at the onLoad event of the <BODY>
0
 
LVL 2

Expert Comment

by:svd2002
ID: 6920516
1. Let the id of the cell be "c1" whose width is to be assigned to <SELECT>
2. Let the id of the <SELECT> be "s1"

Write a function at the client side:
<SCRIPT LANGUAGE=javascript>
<!--
     function f()
     {
          s1.style.width = c1.clientWidth;
     }
//-->

This function can be called at the onLoad event of the <BODY>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Accepted Solution

by:
DreamMaster earned 300 total points
ID: 6920529
<select name="servicesPossibles1" width="20" style="width:30px;">

The first width should work for netscape...the style version works for Internet Explorer....

There is however no solid way to keep the select that size...because if any of the options is wider then the size you provided...Netscape will stretch it to the longest item...

Max.
0
 
LVL 4

Author Comment

by:seguret
ID: 6920547
That doesn't work : in fact, I cannot eve access to c1.clientWidth : the following code does nothing :
alert(c1.clientWidth);
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 6920567
Yes Max. is right on; you need to use css to widen your select box; thats the only way;

but just to ensure that all comes in your can change the font and size;

<select name="servicesPossibles1" width="20" style="width:30px; font-family:verdana; font-size:10px; letter-spacing:0px;word-spacing:0px;">

lexxwern
0
 
LVL 4

Author Comment

by:seguret
ID: 6920570
Thanx Maks, it works.
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 6920577
You're welcome sequret...

But if it worked....why the Grade B?

Max.

"Max is like a dream which glides in and out of the dark corners of Experts-Exchange like the early morning mist in a river delta..."

-Netminder-
0
 
LVL 2

Expert Comment

by:svd2002
ID: 6920588
if you cannot get the object with id "c1", try the following:
alert(document.getElementById("c1").clientWidth);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

656 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