473,569 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple check box validation

45 New Member
hi,
Expand|Select|Wrap|Line Numbers
  1. var len=document.form.check.length
  2. flag=false;
  3. for(i=0;i<len;i++)
  4. {
  5. if(document.form.check[i].checked==true)
  6. {
  7. flag=true;
  8. break;
  9. }
  10. }
  11. if(flag==false)
  12. {
  13. alert(select atlest one)
  14. }
  15.  
  16.  
my error is object is required
Feb 25 '08 #1
6 3315
shanmugamit
45 New Member
hi,my error is object is required.please any one help for a problem.....
Expand|Select|Wrap|Line Numbers
  1. var len=document.form.check.length
  2. flag=false;
  3. for(i=0;i<len;i++)
  4. {
  5. if(document.form.check[i].checked==true)
  6. {
  7. flag=true;
  8. break;
  9. }
  10. }
  11. if(flag==false)
  12. {
  13. alert(select atlest one)
  14. }
  15.  
  16.  
Feb 25 '08 #2
vee10
141 New Member
Hi ,

once check whether "form" is the id of the form and check is the id of the checkbox because i am not getting error and this code is fine


Expand|Select|Wrap|Line Numbers
  1. var len=document.form.check.length
  2. flag=false;
  3. for(i=0;i<len;i++)
  4. {
  5. if(document.form.check[i].checked==true)
  6. {
  7. flag=true;
  8. break;
  9. }
  10. }
  11. if(flag==false)
  12. {
  13. alert(select atlest one)
  14. }
  15.  
  16.  
Feb 25 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1. alert(select atlest one)
alert('select at least one') - it should be a string.
Feb 25 '08 #4
shanmugamit
45 New Member
i have mutiple check box value error object required.......
Expand|Select|Wrap|Line Numbers
  1. aa
  2. <script type="text/javascript">
  3. function fnallocate()
  4. {
  5. var len=document.form.selcie.length
  6. flag=false;
  7. for(i=0;i<len;i++)
  8. {
  9. if(document.form.selcie[i].checked==true)
  10. {
  11. flag=true;
  12. break;
  13. }
  14. }
  15. if(flag==false)
  16. {
  17. alert("select atlest one");
  18. }
  19. </script>
  20. <body>
  21. <form action="checkbox.php" name="form" method="post">
  22. <?
  23.  $res=mysql_query("select * from cie where des='Resource Pipeline Associate' order by name");
  24. $j=0;
  25.         $norow=mysql_num_rows($res);
  26.         $flag=false;
  27.     while($td=mysql_fetch_array($res))
  28.     {
  29.                 for($i=0;$i<count($can);$i++)
  30.  
  31.             {    
  32.                     if("$td[1]"=="$can[$i]")
  33.                     {
  34.                         $flag=true;
  35.                         $i=count($can);
  36.                     }
  37.                     else
  38.                     {
  39.                     $flag=false;
  40.                     }
  41.             }
  42.                 if($flag==true)
  43.                 {
  44. //print"        <tr><td><input type=\"checkbox\" name=\"selcie\"  value=\"$td[1]\" checked>$td[1]</td></tr>";
  45.                 }
  46.                 else
  47.                 {
  48. print"        <tr><td><input type=\"checkbox\" name=\"selcie\" value=\"$td[1]\" >$td[1]</td></tr>";                
  49.                 }
  50.                 $j++;
  51.     }    
  52. ?>         
  53.   <input type="submit" name="Submit" value="Submit" onclick="fnallocate()">
  54. </form>
  55. <?
  56.  
  57.  
  58. if(isset($_POST['Submit']))
  59. {
  60.     for ($i=0; $i<count($_POST['selcie']);$i++) {
  61.        echo "<br />value $i = ".$_POST['selcie'][$i];
  62.     }
  63. }
  64. ?>
  65. </body
  66.  
Feb 26 '08 #5
hsriat
1,654 Recognized Expert Top Contributor
[php]
<script type="text/javascript">
function fnallocate(len) {
for(i=0;i<len;i ++) {
if(document.get elementById('se lcie_'+i).check ed==true)
return true;
}
alert("select atlest one");
return false;
}
</script>
<body>
<form action="checkbo x.php" name="form" method="post">
<?
$res=mysql_quer y("select * from cie where des='Resource Pipeline Associate' order by name");
$j=0;
$norow=mysql_nu m_rows($res);
$flag=false;
while($td=mysql _fetch_array($r es))
{
for($i=0;$i<cou nt($can);$i++)
{
if($td[1]==$can[$i])
{
$flag=true;
$i=count($can);
}
else
{
$flag=false;
}
}
if($flag==true)
{
echo "<tr><td><i nput type=\"checkbox \" id=\"selice_".$ j."\" name=\"selcie[]\" value=\"$td[1]\" checked>$td[1]</td></tr>";
}
else
{
echo "<tr><td><i nput type=\"checkbox \" id=\"selice_".$ j."\" name=\"selcie[]\" value=\"$td[1]\" >$td[1]</td></tr>";
}
$j++;
}
?>
<input type="submit" name="Submit" value="Submit" onclick="return fnallocate(".($ j-1).")">
</form>
<?
if(isset($_POST['Submit']))
{
for ($i=0; $i<count($_POST['selcie']);$i++)
{
echo "<br />value $i = ".$_POST['selcie'][$i];
}
}
?>
</body>
[/php]

Try it this time...
Feb 26 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
i have mutiple check box value error object required...
Threads merged. Please do not double post.

Moderator
Feb 26 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4959
by: Phil Powell | last post by:
Has anyone here ever done a case where you have a select multiple form element and you have to do both server-side and client-side validation? I am honestly not sure how to do it in Javascript (I keep getting errors thrown that I can't verify because the form processes onto itself too quickly for me to check the Javascript errors) because...
4
5358
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm...
1
3909
by: Ken Varn | last post by:
If a page has multiple ValidationSummary controls, how does it distinguish which ValidationControls are associated with which ValidationSummary controls? The reason I am asking this is that I want to display a Message Box for the validation message on my Validation controls. My validation control is embedded within a custom server control....
1
2111
by: epigram | last post by:
I'm trying to use the ASP.NET validators to check some client-side business rules. I've got two ASP TextBox controls (call them tbxYear1 and tbxYear2) used to enter a range of years. I've got a couple things I need to check: 1) tbxYear1 and tbxYear2 are both optional, but if values are entered they have to integers and non-negative 2) if...
4
7255
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm using an include to pull in form elements (text fields, checkboxes, etc...) multiple times on a single page. The included page does not have a form...
5
4943
by: paul_zaoldyeck | last post by:
does anyone know how to validate an xml file against multiple defined schema? can you show me some examples? i'm making here an xml reader.. thank you
2
2384
by: Neo Geshel | last post by:
Greetings, I have a form with a telephone field. It is very specific, as it has four text boxes - the country code, area code, prefix and suffix. I can validate each of them individually, but I am stumped as to how to validate them as a group (as one final validation). I need to check to see if all (at one time) are filled or empty. The...
2
6792
by: forbes | last post by:
Hi, I have a form that contains multiple groups of checkboxes that act like radio buttons (at the clients insistance). There is one text field that is required and 28 checkbox groups. Here an example of a checkbox group: <td><input type="checkbox" name="trusted" value="1" id="ck_ttt1" onclick="... <td><input type="checkbox"...
4
4858
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to mydirectory, but for some reason, I am getting different file names on the database. Here is the full code: please do serach on kewword "database" to...
0
7926
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
8132
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
7678
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
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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
5222
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
3656
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.