Super Web Mart - Discount Coupons & Deals - Discount Promos, Coupon Codes, Discount deals and web site reviews
 

Author Topic: Checkbox Problem  (Read 2066 times)

0 Members and 1 Guest are viewing this topic.

Offline indigo

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
Checkbox Problem
« on: December 02, 2007, 11:42:07 PM »
I have been trying to simply check the number of check boxes that are checked off in a group. The checkboxes are dynamically spit out by a database query and have the name "id".

Here is the code that is invoked when the form is sumitted:


Code: [Select]
function verifyDelete(form){

var max = form.id.length;
alert('Max is: ' + max);
var conf;
var count = 0;
var i;

alert(document.delDocs.id.checked);

for (i = 0; i < max; i++) {
if (eval("document.delDocs.id[" + i + "].checked") == true) {
count += 1;
}
}

//if the count is great than 0 confurm the users intention and allow the form to be submitted
if (count > 0){
conf = confirm("Perform deletion? Remember, this is not undoable.");

if (conf)
return true;
else
return false;
}
else{
alert("You have not selected any files to delete.\nPlease make a selection and try again.");
return false;
}
}


This code works fine when there is more than 1 box in the group.
However, when there is only 1 checkbox, nothing happens.

Any help is appreciated.



Webmaster Forum

Checkbox Problem
« on: December 02, 2007, 11:42:07 PM »

Offline rachel

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Checkbox Problem
« Reply #1 on: December 10, 2009, 11:33:33 PM »
i have faced many time problem in check box, but when you will get experience in java script  then you will not face and you can solve your problem very easy.

Offline william90980

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Checkbox Problem
« Reply #2 on: September 02, 2010, 10:09:19 PM »
 Hello!

This code works in IE6 & 7 & FF but not Safari in windows.

var prod_id = "C1"

if (document.getElementById(prod_id).checked)
alert("1")
else
alert("0")

There is a checkbox, and another link, when i click the link it should alert 0 if the checkbox is not checked and 1 if it is checked.

It works fine in IE6 & 7 & FF but in Safari windows, it always alerts 0.

So what is the way to let it work in Safari too?

Thanks in advance



« Last Edit: September 02, 2010, 11:53:57 PM by seochapter »

Webmaster Forum

Re: Checkbox Problem
« Reply #2 on: September 02, 2010, 10:09:19 PM »