473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checkbox multi column alignment

I have a check box with let's say 20 elements. I would like to have it
align as 4 columns, 5 rows. Without using a table and using
understandable CSS is there any way to make the check boxes align as I
would like?

I've been playing with the following selector in my attempts to get at
the text portion: input[type="checkbox"] + * {width:180px;}
So far my attempts have produced weirdness in FF and nothing occurs in IE7.

Although beyond the scope of this Newsgroup, when a span is placed
around each checkbox the following Javascript does cause the elements to
align in IE7, but not FF or Opera
<span><INPUT TYPE='checkbox' NAME='Countries[]' VALUE='US' >United
States</span>

var Boxes = document.getEle mentsByName("Co untries[]")
for(i=0; i<Boxes.length ; i++)
{
Boxes[i].parentNode.sty le.width = 180 + "px"
}
Thank you
Mar 30 '07 #1
11 16445
On 2007-03-30, totalstranger <to***********@ not.yahoo.netwr ote:
I have a check box with let's say 20 elements. I would like to have it
align as 4 columns, 5 rows. Without using a table and using
understandable CSS is there any way to make the check boxes align as I
would like?

I've been playing with the following selector in my attempts to get at
the text portion: input[type="checkbox"] + * {width:180px;}
So far my attempts have produced weirdness in FF and nothing occurs in IE7.
The recommended default stylesheet for CSS 2.1 says input should be
display: inline-block, which neither FF nor IE7 support.

You might be best to float them, or put them in containers which you
float and set width and height on. So long as you set all the containers
to the same heights they'll flow much like inline blocks.
Mar 30 '07 #2
Scripsit Ben C:
The recommended default stylesheet for CSS 2.1 says input should be
display: inline-block, which neither FF nor IE7 support.
IE has had limited support to display: inline-block since IE 5.5.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Mar 30 '07 #3
Scripsit totalstranger:
I have a check box with let's say 20 elements.
You can't. A checkbox is a single element. You should have posted the URL
for many reasons, including the fact that it might give us a hint of what
you have really got.
I would like to have it
align as 4 columns, 5 rows.
Align? It seems that you would like to put them into a table. Why? Oh, never
mind. Just _don't_.
Without using a table and using
understandable CSS is there any way to make the check boxes align as I
would like?
Just the textboxes? With no labels? How would that be useable?
<span><INPUT TYPE='checkbox' NAME='Countries[]' VALUE='US' >United
States</span>
So you _do_ have some labels, just with inadequate markup.

Trying to guess what you _really_ want, I'd suggest markup like

<label><INPUT TYPE='checkbox' NAME='Countries[]' VALUE='US' >United
States</label>

with a style sheet like

label { display: block; float: left; width: 9em;}

You need to make a guess on a sufficiently large value for the width
property, based on an estimate of the length of the longest label. Do not
proceed before you understand why it would be all wrong to set the width in
pixels.

Anyway, this is not _useful_. It might be barely reasonable for 20
countries, but not for 200 countries. The friendly way to prompt for country
is a text input field where the user can type a name or a two- or
three-letter country code. The author needs to take care of the boring work
of finding or writing a server-side script that checks the country name and
code (and prompts again when needed), instead of forcing to user to do
boring lookup work.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 30 '07 #4
On 2007-03-30, Jukka K. Korpela <jk******@cs.tu t.fiwrote:
Scripsit Ben C:
>The recommended default stylesheet for CSS 2.1 says input should be
display: inline-block, which neither FF nor IE7 support.

IE has had limited support to display: inline-block since IE 5.5.
I'm not sure I buy the idea that there can be degrees of support for
inline-block. It's well defined by CSS 2.1 and you either support it or
you don't.
Mar 30 '07 #5
Scripsit Ben C:
I'm not sure I buy the idea that there can be degrees of support for
inline-block. It's well defined by CSS 2.1 and you either support it
or you don't.
You could support a CSS feature every other day, or for pages containing the
string "42", or (most commonly) most of the time, so that it usually works
but sometimes doesn't.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 30 '07 #6
On 2007-03-30, Jukka K. Korpela <jk******@cs.tu t.fiwrote:
Scripsit Ben C:
>I'm not sure I buy the idea that there can be degrees of support for
inline-block. It's well defined by CSS 2.1 and you either support it
or you don't.

You could support a CSS feature every other day, or for pages containing the
string "42", or (most commonly) most of the time, so that it usually works
but sometimes doesn't.
Has display:inline-block, as specified by CSS 2.1, ever worked on any or
any other day, even for a page containing the string "42", in any
version of IE, ever?
Mar 30 '07 #7
On or about 3/30/2007 2:01 PM, it came to pass that Jukka K. Korpela wrote:
Scripsit totalstranger:
>I have a check box with let's say 20 elements.

You can't. A checkbox is a single element. You should have posted the
URL for many reasons, including the fact that it might give us a hint of
what you have really got.
>I would like to have it
align as 4 columns, 5 rows.

Align? It seems that you would like to put them into a table. Why? Oh,
never mind. Just _don't_.
>Without using a table and using
understandab le CSS is there any way to make the check boxes align as I
would like?

Just the textboxes? With no labels? How would that be useable?
><span><INPUT TYPE='checkbox' NAME='Countries[]' VALUE='US' >United
States</span>

So you _do_ have some labels, just with inadequate markup.

Trying to guess what you _really_ want, I'd suggest markup like

<label><INPUT TYPE='checkbox' NAME='Countries[]' VALUE='US' >United
States</label>

with a style sheet like

label { display: block; float: left; width: 9em;}

You need to make a guess on a sufficiently large value for the width
property, based on an estimate of the length of the longest label. Do
not proceed before you understand why it would be all wrong to set the
width in pixels.

Anyway, this is not _useful_. It might be barely reasonable for 20
countries, but not for 200 countries. The friendly way to prompt for
country is a text input field where the user can type a name or a two-
or three-letter country code. The author needs to take care of the
boring work of finding or writing a server-side script that checks the
country name and code (and prompts again when needed), instead of
forcing to user to do boring lookup work.
Not sure why you say it's not useful, this works perfectly FF 2.0.0.3,
Opera9 and IE7--Big Thank you. As a bonus when a click is done on the
Checkbox text the field is selected or unselected respectively.

My issue with this form is that many countries, and many of their
respective states/provinces/regions/etc may be selected. This makes
(IMHO) an AJAX control a bit complex, and I can't justify the coding
time(mine) since this is a very low usage, administrative only form. I'm
going with way less than the full compliment of 244 countries defined at
http://www.iso.org/iso/en/prods-serv.../list-en1.html
so it should work. It will also work well for the 50 US states and the
13 Canadian provinces/territories, and whatever other jurisdictions I
have to deal with.

"Yeah you right" I need to do more reading on em vs px, also the html
label tag, and probably much more.

Thank you once again
Arn
Mar 30 '07 #8
Scripsit totalstranger:
Not sure why you say it's not useful, this works perfectly FF 2.0.0.3,
Opera9 and IE7--Big Thank you. As a bonus when a click is done on the
Checkbox text the field is selected or unselected respectively.
It works technically, and the <labelmarkup indeed makes the checkboxes
toggleable by clicking on the text too. But "it" referred to the whole idea
of creating a large set of checkboxes. Actually I have assumed that you
actually meant to use _radio buttons_, to allow a "1 out of many" choice,
rather than checkboxes, which allow "any out of many" choices. Now that I
come to think of, if you _really_ need the latter, the checkboxes might make
sense after all, in some cases.
My issue with this form is that many countries, and many of their
respective states/provinces/regions/etc may be selected.
OK, I see. I was thinking about the much more common situation where a
single country (or state or province) is to be selected, e.g. the country
where the user lives. Authors often do such things with <selectelemen ts
with all the countries they ever heard of, which is bad, or with a similarly
large set of radio buttons, which is bad too, insted of simply letter the
user type "US" or "USA" or "United States", or something like that. For
multiple choices, text input approach works too, but in cases like yours,
the checkboxes are probably a better idea.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 31 '07 #9
Sub titulo "Re: Checkbox multi column alignment"
cripsit Ben C:
Has display:inline-block, as specified by CSS 2.1, ever worked on any
or any other day, even for a page containing the string "42", in any
version of IE, ever?
Surely. The magic needed is not very magical in this case: you need to set
the width of the element. The main problem with display: inline-block on IE
is that the width incorrectly defaults to the available width.

This of course defeats much of the potential use, but display: inline-block
still partially works on IE. You can test this e.g. by using <spanmarkup
for some word in a paragraph and setting a width for it, and perhaps
background or border to make the width easier to see. IE will correctly
ignore the width setting, since <spanis by default an inline element. When
you set display: inline-block, the width starts working, as specified, and
the element still appears inline.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Mar 31 '07 #10

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

Similar topics

5
8324
by: javaguy | last post by:
I have a data entry web application that is formatted heavily with tables. Having learned a bit of CSS, I'm hoping to rewrite this using <div> tags. But I have run into a formatting problem that keeps me from a solution. I'm hoping for some trick. Assume that "label_a" is a <label> tag and "INPUT_A" is an <input> tag. A sample of my...
1
12445
by: Marcos MOS | last post by:
Hi all, How Can I build a DataGrid with a "checkbox column" for all rows? And after I'll need to know if that row's checkbox is checked or not... I know that the better way is "template" column, but I don't have idea... thanks a lot Marcos
0
339
by: Jim Ptak via .NET 247 | last post by:
I am desperate for help. I am at a loss. I have a dataset with 4columns in it. The first column is an actual column from adatabase table. The last three columns are hard codded values of0. I am using this dataset to populate a datagrid. The datagridhas a datagridtablestyle that has all four columns with the lastthree being DataGridBoolColumn's....
0
2392
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a CheckBox Programmatically" in my code. I have changed it to use a OLDDB.DBReader to populate the datagrid and for the databinding. It works perfectly -...
10
2408
by: Jennyfer J Barco | last post by:
Hello, I have a datagrid that brings some information from a query. I need to have a checkbox in each row so the user can select the rows he wants to reprint. Is it possible to have a checkbox control in a datagrid? Now I have a Select column but the problem is that the user needs to select more than one record and send them all to print,...
2
1144
by: Thomas A | last post by:
Hi ! I'm trying to use a datagrid with an checkbox column, I not shoure to get it work on several points I have got the rest of the data mapped to the grid but the checkbox doesnt work. 1. The column type in the sql is Integer (values 0 or 1), is this ok or should I change it to something else?
4
4423
by: magmo | last post by:
Hi I have created a windows form that hold a datagrid, that datagrid gets it values from a stored procedure. My problem is that I have added a checkbox to the datagrid and applied some style to the datagrid. But the checkbox is always greyed out. Why is that, and what am I doing wrong? Here's my code...
17
7416
by: Mike Fellows | last post by:
im trying (unsucessfully) to add a checkbox column to my datagrid i basically have a datagrid that im populating from a dataset Me.DataGrid1.DataSource = ds.Tables(0) the datagrid then has 5 columns in it but i need to add a sixth column which will be my checkbox column - any help or pointers with this would be great
4
5581
by: Steve | last post by:
Hi all, I don't want to use the datagrid if I don't have to. Is there a way to setup a ListBox to have more than one checkbox column? I need something like this | Include || Set as Default || Other columns... | asdasdasd digity-digity!
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7638
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.