473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multiple check box validation

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 3297
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 100+
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 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. alert(select atlest one)
alert('select at least one') - it should be a string.
Feb 25 '08 #4
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 Expert 1GB
[php]
<script type="text/javascript">
function fnallocate(len) {
for(i=0;i<len;i++) {
if(document.getelementById('selcie_'+i).checked==t rue)
return true;
}
alert("select atlest one");
return false;
}
</script>
<body>
<form action="checkbox.php" name="form" method="post">
<?
$res=mysql_query("select * from cie where des='Resource Pipeline Associate' order by name");
$j=0;
$norow=mysql_num_rows($res);
$flag=false;
while($td=mysql_fetch_array($res))
{
for($i=0;$i<count($can);$i++)
{
if($td[1]==$can[$i])
{
$flag=true;
$i=count($can);
}
else
{
$flag=false;
}
}
if($flag==true)
{
echo "<tr><td><input type=\"checkbox\" id=\"selice_".$j."\" name=\"selcie[]\" value=\"$td[1]\" checked>$td[1]</td></tr>";
}
else
{
echo "<tr><td><input 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 Expert Mod 8TB
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
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...
4
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...
1
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...
1
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...
4
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...
5
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
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...
2
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...
4
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.