[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Give alert if form checkbox array is empty

Bunyip

1/20/2016 3:28:00 AM

I have a form as follows:

<form enctype="multipart/form-data" method="post" action="index.html"
name="artwork" onsubmit="return check_artwork_submit()">

<input type="checkbox" name="subjectType[]" value="Abstract" />
Abstract<br />
<input type="checkbox" name="subjectType[]" value="Animal" />
Animal<br />
<input type="checkbox" name="subjectType[]" value="Impressionist" />
Impressionist<br />
<input type="checkbox" name="subjectType[]" value="Landscape" />
Landscape

<input type="submit" value="Add artwork" name="add_artwork">
</form>

I need to check that at least one sunbjectType[] has been checked and,
if not, throw an alert.

I've tried e.g.:

var subjectType_count = document.getElementByName('subjectType[]');
var is_checked = false;
for (var i = 0; i < subjectType_count; i++) {
if (document.artwork.elements['subjectType[]'].checked) {
is_checked = true;
break;
}
}
if (is_checked == false) {
alert('Please enter the subject type');
}

....and other snippets but none of them throws the alert. Can anybody
help with this please?

TIA
69 Answers

Rogues Island's finest

8/30/2010 12:22:00 PM

0

On Aug 29, 11:58 pm, "DGDevin" <DGDe...@invalid.invalid> wrote:
> "musicfinder" <prince...@hotmail.com> wrote in message
>
> news:8aa040b3-e98f-42db-ae94-9026db6304de@s17g2000prh.googlegroups.com...
>
> > First thanks to all who are reading this. I just picked up a Ipod nano
> > and I have begun starting to run and would very much like to add some
> > Dead shows to the nano,
>
> I suggest not using the ear-buds that came with the iPod (or anything like
> them) because they are too good at blocking outside sounds and when you're
> running it's nice to be able to hear that five-ton truck coming up the road
> behind you.  I use headphones with a band that wraps around behind my head
> so I can wear a hat or sunglasses to keep the sun out of my eyes.  Since the
> headphones sit on my ears rather than plugging into the ear canal I can
> still hear outside noises, makes me feel a little safer.
>
> Something like this:
>
> http://www.amazon.com/Sony-MDR-G57G-Sports-Headphones-Refle......

Good advice, except for one thing: never, EVER run with traffic. Run
against traffic, because you surely want to see that old lady who
refused to go around you or the teenage girl texting BEFORE they hit
you from behind.

I lost count of the number of times I had to veer into the weeds to
avoid some of these idiots.

Mark

Sweetbac

8/30/2010 2:29:00 PM

0


"Rogues Island's finest" <mthitch@cox.net> wrote in message

> I lost count of the number of times I had to veer into the
> weeds to avoid some of these idiots.

> Mark

You sure it wasn't family members, Nantucket?
You keep running off to see that band of yours,
the wife is gonna get a bit frustrated!
Nah...I'd sleep with one eye open if I was you, Champ!


DGDevin

8/30/2010 6:24:00 PM

0

"Rogues Island's finest" <mthitch@cox.net> wrote in message
news:2ba82920-ced7-4842-bcba-d183e471cd72@t2g2000yqe.googlegroups.com...

> Good advice, except for one thing: never, EVER run with traffic. Run
> against traffic, because you surely want to see that old lady who
> refused to go around you or the teenage girl texting BEFORE they hit
> you from behind.

Some places you can get a ticket for doing that, ditto with riding a bike
against traffic. Legally it appears that if you're on the road you're
supposed to be facing the same way as the other traffic. Good reason not to
run on the road.

> I lost count of the number of times I had to veer into the weeds to
> avoid some of these idiots.
>
> Mark

I keep off the streets, but I still like to hear what's going on around me.

Rogues Island's finest

8/30/2010 7:45:00 PM

0

On Aug 30, 2:24 pm, "DGDevin" <DGDe...@invalid.invalid> wrote:
> "Rogues Island's finest" <mthi...@cox.net> wrote in messagenews:2ba82920-ced7-4842-bcba-d183e471cd72@t2g2000yqe.googlegroups.com...
>
> > Good advice, except for one thing: never, EVER run with traffic.  Run
> > against traffic, because you surely want to see that old lady who
> > refused to go around you or the teenage girl texting BEFORE they hit
> > you from behind.
>
> Some places you can get a ticket for doing that, ditto with riding a bike
> against traffic.  Legally it appears that if you're on the road you're
> supposed to be facing the same way as the other traffic.  Good reason not to
> run on the road.

Well then some places are idiots. I am not aware of any laws around
here regarding forcing people to run with traffic coming up behind
them. Bikes and running are two very different things and the rule/
wisdom around here is that you ride with traffic and run against it.
Running with traffic is suicide imo.

> > I lost count of the number of times I had to veer into the weeds to
> > avoid some of these idiots.
>
> > Mark
>
> I keep off the streets, but I still like to hear what's going on around me.

I'd never listen to music running on a road, but I sure dig a nice
loooooong FOTM while running on a bike path (into traffic, btw...that
is the rule of the bike paths around here too, ride right, walk/run
left)..what a perfect running song.

Mark

Brad Greer

8/31/2010 3:39:00 AM

0

On Mon, 30 Aug 2010 12:44:33 -0700 (PDT), "Rogues Island's finest"
<mthitch@cox.net> wrote:

>On Aug 30, 2:24?pm, "DGDevin" <DGDe...@invalid.invalid> wrote:
>> "Rogues Island's finest" <mthi...@cox.net> wrote in messagenews:2ba82920-ced7-4842-bcba-d183e471cd72@t2g2000yqe.googlegroups.com...
>>
>> > Good advice, except for one thing: never, EVER run with traffic. ?Run
>> > against traffic, because you surely want to see that old lady who
>> > refused to go around you or the teenage girl texting BEFORE they hit
>> > you from behind.
>>
>> Some places you can get a ticket for doing that, ditto with riding a bike
>> against traffic. ?Legally it appears that if you're on the road you're
>> supposed to be facing the same way as the other traffic. ?Good reason not to
>> run on the road.
>
>Well then some places are idiots. I am not aware of any laws around
>here regarding forcing people to run with traffic coming up behind
>them. Bikes and running are two very different things and the rule/
>wisdom around here is that you ride with traffic and run against it.
>Running with traffic is suicide imo.
>
I've always been taught to walk/run into traffic, for the reasons
Nantucket states. Never heard of a law against it.

Brad Greer

8/31/2010 3:39:00 AM

0

On Mon, 30 Aug 2010 05:21:32 -0700 (PDT), "Rogues Island's finest"
<mthitch@cox.net> wrote:

>On Aug 29, 11:58?pm, "DGDevin" <DGDe...@invalid.invalid> wrote:
>> "musicfinder" <prince...@hotmail.com> wrote in message
>>
>> news:8aa040b3-e98f-42db-ae94-9026db6304de@s17g2000prh.googlegroups.com...
>>
>> > First thanks to all who are reading this. I just picked up a Ipod nano
>> > and I have begun starting to run and would very much like to add some
>> > Dead shows to the nano,
>>
>> I suggest not using the ear-buds that came with the iPod (or anything like
>> them) because they are too good at blocking outside sounds and when you're
>> running it's nice to be able to hear that five-ton truck coming up the road
>> behind you. ?I use headphones with a band that wraps around behind my head
>> so I can wear a hat or sunglasses to keep the sun out of my eyes. ?Since the
>> headphones sit on my ears rather than plugging into the ear canal I can
>> still hear outside noises, makes me feel a little safer.
>>
>> Something like this:
>>
>> http://www.amazon.com/Sony-MDR-G57G-Sports-Headphones-Refle......
>
>Good advice, except for one thing: never, EVER run with traffic. Run
>against traffic, because you surely want to see that old lady who
>refused to go around you or the teenage girl texting BEFORE they hit
>you from behind.
>
>I lost count of the number of times I had to veer into the weeds to
>avoid some of these idiots.
>
Well, if you're going to insist on driving on the sidewalk while
updating your Facebook status these things will happen, you know.

DGDevin

8/31/2010 5:18:00 PM

0

"Brad Greer" <jjh1102us@yahoo.com> wrote in message
news:78uo761cvtvk4e2kilc7t25njp5forcla6@4ax.com...

> I've always been taught to walk/run into traffic, for the reasons
> Nantucket states. Never heard of a law against it.

I'm probably confusing laws against riding a bike against traffic with
running against traffic in places where there isn't a sidewalk. I'm old and
my memory is, ummm, what's the word?

Rogues Island's finest

8/31/2010 8:35:00 PM

0

On Aug 31, 1:17 pm, "DGDevin" <DGDe...@invalid.invalid> wrote:
> "Brad Greer" <jjh110...@yahoo.com> wrote in message
>
> news:78uo761cvtvk4e2kilc7t25njp5forcla6@4ax.com...
>
> > I've always been taught to walk/run into traffic, for the reasons
> > Nantucket states.  Never heard of a law against it.
>
> I'm probably confusing laws against riding a bike against traffic with
> running against traffic in places where there isn't a sidewalk.  I'm old and
> my memory is, ummm, what's the word?

What?

Mark

mr.rapidan

8/31/2010 9:39:00 PM

0

> running against traffic in places where there isn't a sidewalk.

I think running on sidewalks is bad form - I just never do it. Most
of my running is on trails, anyway, but when I do run on streets, it's
always on the road - in the dark, bad weather, whatever.

Just curious what other people do.

I suppose there are urban situations in which running on a road is
instant death . . . didn't consider that.

DGDevin

8/31/2010 10:31:00 PM

0

"dr.narcolepsy" <jminpa@gmail.com> wrote in message
news:26ff2e11-2750-473f-ab58-ef465e64153e@k10g2000yqa.googlegroups.com...

>> running against traffic in places where there isn't a sidewalk.
>
> I think running on sidewalks is bad form - I just never do it. Most
> of my running is on trails, anyway, but when I do run on streets, it's
> always on the road - in the dark, bad weather, whatever.

I have no problem with someone running on a sidewalk unless it is too
crowded to run without inconveniencing other pedestrians, in that case it's
equivalent to doing calisthenics on a crowed bus.

> Just curious what other people do.
>
> I suppose there are urban situations in which running on a road is
> instant death . . . didn't consider that.

Ditto with riding a bike in city traffic, you really need to have your wits
about you as there is always some moron to whom bikes and their riders are
invisible.