473,698 Members | 2,305 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
11 16471
On 2007-03-31, Jukka K. Korpela <jk******@cs.tu t.fiwrote:
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.
Maybe that would have been enough for the OP (not that I call it
"working"). But FF is still a problem. Now he could experiment with
-moz-inline-box, but better to stay on the beaten track I think and use
floats.
Mar 31 '07 #11
On or about 3/31/2007 1:46 AM, it came to pass that Jukka K. Korpela wrote:
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 <select>
elements 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.
For a 1 out of many I generally prefer select boxes, aka dropdowns. Most
readers/users simply don't understand how to use a multiple select box
while holding the CTRL key, and they are difficult to use when the
number of elements is very large. In this case I use an AJAX search
control pulling a subset of the data from the database for the select box.

(Back to the checkbox CSS issue)
Sometimes the checkbox does not show the way I expect in FF when an
unrelated bit of HTML is hidden using ECMAscript/Javascript. I have to
try this in IE and Opera.

This page establishes regional geographical editions. My focus at this
point is getting it to work so I can properly load a MySql table, then
use the table as part of my plan to fully internationaliz e my site.
After that I'll get back to the making this page look good.

Arn
http://www.arnb.org/Schedule.php
Mar 31 '07 #12

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

Similar topics

5
8329
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 current web page is: <table> <tr><td>label_a</td><td>INPUT_A</td>
1
12449
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. This works great when I hit aSQL Server database. When I hit an Oracle database thecheckboxes are...
0
2401
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 - also when using the edit-mode in the datagrid.
10
2435
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, instead of being one by one like is now with the Select column. Another question, is it possible to...
2
1150
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
4424
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
7427
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
5589
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
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8895
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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

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.