Jump to content

Recommended Posts

I'm trying to use checkbox to choose multiple data and submit(button 'Send SMS') them and direct them to another page, which will send text SMS to the numbers chosen. But when I try to click on one checkbox, it automatically directs me to the next page, without having to click on the 'Send SMS' button. I tried to see which part is the problem, but I can't determine which one is wrong.  Please help! Thank you.

<script type="text/javascript">
function checkedAll (frm1) {var aa= document.getElementById('frm1'); if (checked == false)
{
checked = true
}
else
{
checked = false
}for (var i =0; i < aa.elements.length; i++){ aa.elements[i].checked = checked;}
}
</script>

<TABLE width="1106" border="1" align="center" cellpadding="5" cellspacing="2" >

       <tr>

       <td colspan="9"> 
         <form id ="frm1" action="sms_latecomers.php">

       <input type='checkbox' name='checkall' onclick='checkedAll(frm1);' value="">

       <input type="submit" name="Submit" id="button" value="SMS Reminder" style="background:#FFCC33"/>


   </td>
 </tr>

       <TR bgcolor="#996699">
        <?php 
       $count=0;
       ?>
       <TH width="32"></TH>
           <TH width="37"> <span class="style1">
         <div align="center">No. </div></span></TH>
         <th width="101"><span class="style1">SUPERVISOR ID</span></th>
         <th width="101"><span class="style1">EMPLOYEE ID</span></th>
         <th width="153"><span class="style1">EMPLOYEE NAME</span></th>
         <th width="124"><span class="style1">DATE</span></th>
         <th width="153"><span class="style1">LATE CHECK IN</span></th>




       </TR>
       <?php 
       while($row = mysql_fetch_array($result, MYSQL_ASSOC))
       {
       ?>
       <TR>
           <TD><input type="checkbox" name="chk1" value="<?php echo $row['supervisor_telno']; ?>" onClick="window.open('sms_latecomers.php?employee_id=<?php echo $row['employee_id'];  ?>&supervisor_telno=<?php echo $row['supervisor_telno']; ?>');"></TD>

           <TD height="66">[bad html removed]<input type="checkbox" name="chk1" >--> <?php $count=$count+1; print($count);?></TD>
           <TD><div align="center"><?php echo $row['supervisor_id']; ?></div></TD>
           <TD><div align="center"><?php echo $row['employee_id']; ?></div></TD>
           <TD><div align="center"><?php echo $row['employee_name']; ?></div></TD>
           <TD><div align="center"><?php echo $row['DATE']; ?></div></TD>
           <TD><div align="center"><?php echo $row['TIME']; ?></div></TD>



       </TR>
       <?php 
       }
       ?>[bad html removed]</form>-->
   </TABLE>
Link to comment
https://forums.phpfreaks.com/topic/292377-checkbox-button-not-working-properly/
Share on other sites

Way too many errors in this code to even try to understand.  Why do you even attempt to pass that frm1 thing as a constant to the js function when in the js you don't even try to use the supposed-passed-in argument?  Why do you use a td to encase both a span and a div just to apply styles when you could just do it to the td tag itself?

 

so much work to do......

 

One suggestion - work on separating your html from your logic.  One is just that logic - the other is presentation.  Don't mix the two except where necessary.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.