IT Community - Software Programming, Web Development and Technical Support

I have multi checkbox in my form...

This is a discussion on I have multi checkbox in my form... within the PHP Programming forums, part of the Web Development category; I have multi checkbox in my form.,then how i validate in any one checkbox is filled,otherwise,display errormessage. ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-15-2007, 09:45 PM
gk_cloud gk_cloud is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 15
gk_cloud is on a distinguished road
Default I have multi checkbox in my form...

I have multi checkbox in my form.,then how i validate in any one checkbox is filled,otherwise,display errormessage.

Using javascript..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-22-2007, 04:31 AM
senraj senraj is offline
D-Web Master
 
Join Date: Jul 2007
Posts: 418
senraj is on a distinguished road
Post Re: I have multi checkbox in my form...

hi,

<script language="JavaScript" type="text/javascript">
<!--

var cbAry=new Array('tom','fred');
var cbNameAry=new Array('X','X');
var ips,OK;

function InitCkBx()
{
ips=document.getElementsByTagName('INPUT');
for (i=0;i<ips.length;i++)
{
if (ips[i].type=='checkbox')
{
for (i1=0;i1<cbAry.length;i1++)
{
if (ips[i].name.match(cbAry[i1]))
{
if (cbNameAry[i1]=='X')
{
cbNameAry[i1]=new Array();
}
cbNameAry[i1][cbNameAry[i1].length]=ips[i];
}
}
}
}
}

function CkBxCheck()
{
for (i=0;i<cbNameAry.length;i++)
{
OK=0;
for (i1=0;i1<cbNameAry[i].length;i1++)
{
if (cbNameAry[i][i1].checked)
{
OK=1
}
}
if (!OK)
{
alert('None Checked in Group '+cbAry[i]);
}
}

}

//-->
</script></head>

<body onload="InitCkBx()" >
<br>
Group fred<br>
<input type="checkbox" name="fred1">
<input type="checkbox" name="fred2">
<input type="checkbox" name="fred3">
<input type="checkbox" name="fred4">

<br>
Group tom<br>
<input type="checkbox" name="tom1">
<input type="checkbox" name="tom2">
<input type="checkbox" name="tom3">
<input type="checkbox" name="tom4">
<br>
<input type="button" name="" value="Check" onclick="javascript:CkBxCheck();" ><br>
</body>

Last edited by senraj : 10-24-2007 at 11:18 PM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-22-2007, 06:31 AM
gk_cloud gk_cloud is offline
D-Web Trainee
 
Join Date: Sep 2007
Posts: 15
gk_cloud is on a distinguished road
Red face Re: I have multi checkbox in my form...

thank you
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date/Time stamp a form field as the form is submitted itbarota HTML, CSS and Javascript Coding Techniques 2 01-17-2008 08:47 PM
checkbox validation rajkumar HTML, CSS and Javascript Coding Techniques 5 11-16-2007 12:32 AM
How can I clear the form field values after the user has submitted the form for clien itbarota HTML, CSS and Javascript Coding Techniques 1 11-01-2007 11:39 PM
How can I pass a hidden value to a form and submit that form when a text link is clic itbarota HTML, CSS and Javascript Coding Techniques 1 10-17-2007 08:07 AM
multi tasking, multi programming, multi threading vigneshgets Operating Systems 1 07-18-2007 05:12 AM


All times are GMT -7. The time now is 05:12 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0