Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7568871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:02:07+00:00 2026-05-30T15:02:07+00:00

This is a snippet of the code that doesn’t work right. The closing </script>

  • 0

This is a snippet of the code that doesn’t work right. The closing </script> tag of the javascript for some reason isn’t recognized. The javascript is for a check all box that will check or uncheck all the checkboxes generated with each form. Each form is separate so I tried to slim down my code by including in the php loop. I had a version of this code working but it involved repeating the same javascript sample multiple times. If you can think of a way to do this differently, feel free to improve the code. At the moment though all I need to figure out why the closing tag of the javascript doesn’t work.

foreach($words as $word){
    $i++;
    $qry = "Select * FROM subs WHERE type = '$word'"; 
    $q = mysql_query($qry) or die(mysql_error()); 
?>

<script type="text/javascript">
    checked=false;

    function checkedAll<?=$i?>(frm<?=$i?>) 
    { 
        var aa= document.getElementById('frm<?=$i?>'); 
        if(checked == false) {
            checked = true
        } 
        else{
            checked = false
        } 

        for(var i =0; i < aa.elements.length; i++) {
            aa.elements[i].checked = checked;
        }
    } 
    </script>
<?
    echo '<form action="attacher.php" method="POST" id="frm'.$i.'" >';
    echo '<input type="hidden" name="template" value="16">';
    echo "<table border='1' cellpadding='10'>";
    echo "<tr><td colspan=4 align='center'><strong>$word</strong></td> <td><input type='submit' value='Add to Template'></td></tr>";
    echo "<tr><th><input type='checkbox' name='checkall".$i."' onclick='checkedAll".$i."'(frm".$i.");'></th><th colspan=3> CONTROLS</th> <th>$word's</th> </tr>";

    // loop through results of database query, displaying them in the table
    while($row = mysql_fetch_array($q)) {   
        // echo out the contents of each row into  table
        echo "<tr>";
        echo '<td><input type="checkbox" name="word[]" value="'.$row['id'].'"</td>';
        echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
        echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
        echo '<td><a href="attacher.php?template=16&word=' . $row['id'] . '">Attach</a></td>';
        echo '<td>' . $row['word'] . '</td>';
        echo "</tr>";
    }
    // close table>
    echo "</table><br>";
    echo '</form>';
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:02:09+00:00Added an answer on May 30, 2026 at 3:02 pm

    I have to mention that the convention of code you use (even if it is one – but I doubt it) isn’t very neat.

    Why don’t you use just some safe variants?
    How about something like this:

    <?php
      //here what you want to do first    
    ?>
    
    <?php
      echo '<script type="text/javascript">
              ....
            </script>';
    ?>
    
    <?php
       echo 'rest of your code';
    ?>
    

    I really don’t recommend using shorttags anyway…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing some code snippet, and I experienced that Visual Studio doesn't automatically add
I have a Perl script that contains this code snippet, which calls the system
I have this code snippet inside a function that checks if an object exists
pretty new to HTML and I was wondering why this snippet of code doesn't
I found this code snippet on a different post that I don't quite understand
I have some JavaScript code that dynamically injects an iframe in a given HTML
I use this code snippet that verifies if the file specified in the URL
I have this snippet of code that looks for the value in a select
I just wrote some JavaScript code that follows along with what I believe to
In this link: http://css-tricks.com/snippets/jquery/jquery-plugin-template/ it has a line of code that says // Add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.