How to control the size(width of a combo box generated in asp?)

J

Jack

Hi,
I have a asp page where multiple rows for a client is generated using asp.
Some of these are combo boxes and some are text and are coming from a
recordset. Now, the following is the code to geneated one of those combo
boxes.

CODE:
<td align="left">
<font face="Verdana,Arial" color="#000000" size="1">
<select name="txtagency">
<option></option>

<%

Set RS_Agency = Server.CreateObject("ADODB.Recordset")
strSQL1 = "SELECT AgencyId, AgencyName FROM tblAgency"
RS_Agency.Open strSQL1, conn


Do Until RS_Agency.EOF 'populate workcodes
if not RS_Edits("AgencyId") = RS_Agency("AgencyID") then
response.write("<option value=" _
& RS_Agency("AgencyID") & ">" _
& RS_Agency("AgencyName") _
& "</option>")
else
response.write("<option selected value=" _
& RS_Agency("AgencyID") & ">" _
& RS_Agency("AgencyName") _
& "</option>")
end if
RS_Agency.movenext
Loop
RS_Agency.Close
set RS_Agency = nothing
%>
</select>
</td>

I need to reduce the size of this combo box. I would like to know, in the
present scenario, how can one control (reduce) the size of the combo box. I
believe what I am getting is the default value of combo box. Thanks.
 
B

Bob Barrows [MVP]

Jack said:
Hi,
I have a asp page where multiple rows for a client is generated using
asp. Some of these are combo boxes and some are text and are coming
from a recordset. Now, the following is the code to geneated one of
those combo boxes.

CODE:
<td align="left">
<font face="Verdana,Arial" color="#000000" size="1">
<select name="txtagency">
I need to reduce the size of this combo box. I would like to know, in
the present scenario, how can one control (reduce) the size of the
combo box. I believe what I am getting is the default value of combo
box. Thanks.

HTML/CSS questions will get better response in one of the newsgroups devoted
to those topics (http://groups.google.com/groups/dir?sel=33584039).

Remember, asp generates the html which is sent to the client. So, before you
can get asp to generate the correct html, you have to learn what the correct
html or css is.

"width" is both an attribute of a SELECT element and a style property. It is
more "accepted" these days to use the css style properties. So add a style
attribute to your SELECT element and put in the width you wish the control
to have.

<select name="txtagency" style="width:50px">

Bob Barrows
 
J

Jack

Thanks a lot Bob. I appreciate your help. I indeed need to learn CSS to know
all these tricks. Best regards.
 
J

Jack

For some reason with the above code there is no change in the width(size) of
the combo box. Any thoughts. Thanks
 
M

Mike Brind

Jack said:
For some reason with the above code there is no change in the width(size) of
the combo box. Any thoughts. Thanks

Yes. Two things. First - please don't top post. Doing that means
there is no "above" code, and is destroys the natural reading order
(from top to bottom).

Second, add a semicolon after the value. CSS declaration syntax is as
follows:

property (colon) value (semicolon)

width: 30px;
 
M

Mike Brind

Mike said:
Yes. Two things. First - please don't top post. Doing that means
there is no "above" code, and is destroys the natural reading order
(from top to bottom).

Second, add a semicolon after the value. CSS declaration syntax is as
follows:

property (colon) value (semicolon)

width: 30px;

That'll teach me.

I get up at 5.00am to watch a bit of cricket, only to find out that bad
light has stopped play, so go log onto the Internet instead, and then
make posts while still only half awake :)


Single declarations like the above do not require semi-colons at the
end of them - they're used to delimit multiple declarations.

Going off to snooze.......
 
B

Bob Barrows [MVP]

In order to figure that out, we (or the html/css group) would need to see
the resulting html. So run your page, View Source, copy out the part of the
source that contains the <SELECT> element (opton tags and all), and post
that (just that - do not post the entire page unless requested to do so) to
the appropriate group. :)

That said, maybe you have to use the SELECT's width attribute after all. It
may depend on the browser ...
I'm a little weak in this area myself and cannot answer these types of
questions off the top of my head without resorting to google and/or
trial-and-error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top