Check Button Validation Help

This is a discussion on "Check Button Validation Help" within the JavaScript Forum section. This forum, and the thread "Check Button Validation Help are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 23rd, 2008, 22:22
Junior Member
Join Date: Feb 2008
Location: England
Age: 21
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Check Button Validation Help

I got 7 checkboxes which are basically sizes for clothing, XS, S, M, L, XL, XXL, and 3XL and I am trying to validate them using javascript, all I need is for it to know if any have been checked, and if none haven't bring up the warning message I already have in place. The only problem I've been getting so far is accessing the check button group I've made, which is an array called Sizes[].

Here's the form code:
Code: Select all
<?php
$CBSizes = array("XS","Small", "Medium", "Large", "XL", "XXL", "3XL");
?>
<span id="mySpan7" class="errmsg"><?php echo $Message_ASizes ?></span><br>
<span class="head4">Available Sizes:</span><br>
<table id="Sizes"><tr>

<?php
$X=0;
       
while($X!=7)
{
   $Size = $CBSizes[$X];
   echo"<td>$Size:</td>";
   echo"<td><input type='checkbox' name='Sizes[]' value='$Size'"; 
   if($SizeA[$Size]==true){echo"Checked";}?>></td></tr><tr>
   <?php
   $X++;
}
?>
</tr></table>
As you can see I use the array CBSizes to grab the names per value of $X, and place all the Sizes into the Sizes[] array. I have a method already in PHP for validating it but I haven't got a working one for Javascript.

Here's the code that's in my main validation function for that section:

Code: Select all
   numBoxesSelected = 0;
   var valuesSelected = new Array;

   for (var i=1; i <= numBoxes; i++) 
   {
      if (eval("document.AddProduct.Sizes" + i + ".checked")) 
      {
         valuesSelected[numBoxesSelected] = eval("document.AddProduct.Sizes" + i + ".value");
     numBoxesSelected++;
      }
   }
   if(numBoxesSelected ==0)
   {
      document.getElementById('mySpan7').innerHTML='! Please choose any relevant Sizes!';
   }
   else
   {
      document.getElementById('mySpan7').innerHTML='';
   }
Reply With Quote

Reply

Thread Tools

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

BB 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
how to change button action into a movieclip button action cjrollo Flash & Multimedia Forum 7 Nov 21st, 2007 17:07
CSS check and error WillisTi Web Page Design 1 Jan 12th, 2006 20:52
When a button refuses to behave like a button in Flash autumn_whispers2me Flash & Multimedia Forum 2 May 24th, 2005 22:08
problem with radio button in form validation augustus_emperor JavaScript Forum 1 Apr 22nd, 2004 13:08
Hello, check this ;) Anonymous User Introduce Yourself 1 Feb 12th, 2004 19:10


All times are GMT. The time now is 10:59.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43