By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,694 Members | 2,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,694 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
Mar 9 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Jack wrote:
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"> <snip>
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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Mar 9 '06 #2

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

"Bob Barrows [MVP]" wrote:
Jack wrote:
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">

<snip>

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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 9 '06 #3

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

"Bob Barrows [MVP]" wrote:
Jack wrote:
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">

<snip>

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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 9 '06 #4

P: n/a
>> Any thoughts. Thanks
Yes. Visit a CSS or HTML group.

Bob Lehmann

"Jack" <Ja**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
For some reason with the above code there is no change in the width(size) of the combo box. Any thoughts. Thanks

"Bob Barrows [MVP]" wrote:
Jack wrote:
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">

<snip>

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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Mar 10 '06 #5

P: n/a

Jack wrote:
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;

--
Mike Brind

Mar 10 '06 #6

P: n/a

Mike Brind wrote:
Jack wrote:
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;

--
Mike Brind


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

--
Mike Brind

Mar 10 '06 #7

P: n/a
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.
Jack wrote:
For some reason with the above code there is no change in the
width(size) of the combo box. Any thoughts. Thanks

"Bob Barrows [MVP]" wrote:
Jack wrote:
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">

<snip>

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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 10 '06 #8

P: n/a
Thanks Bob for your reply. I will do so in the appropriate newsgroup.

"Bob Barrows [MVP]" wrote:
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.
Jack wrote:
For some reason with the above code there is no change in the
width(size) of the combo box. Any thoughts. Thanks

"Bob Barrows [MVP]" wrote:
Jack wrote:
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">
<snip>

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

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Mar 10 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.