How to include html variable to js with PHP

Hi,

I have a code this code is repeated by row with different values per every row, and want to disable the add “plus” button if click on submit button.

I made it by i have to add the row id per each line manually in javascript, I am trying to find a way to make automatically.

my code:

else
      {
      ?>
      <h3 align="center"><?php echo $order_receiver_name; ?> - Cost  </h3>

      <br />
      <div align="right">
        <a href="cost.php?add=1" class="btn btn-info btn-xs">Create</a>
      </div>e
      <br />
      <table id="data-table" class="table table-bordered table-striped">
        <thead>
          <tr>
            <th>Cost No.</th>
            <th>Cost Date</th>
             <th>Project Name</th>
             <th>Project No.</th>
             <th>The Secotor</th>
            <th>Client Name</th>
            <th>Client Mobile</th>
            <th>Total Cost</th>
            <th>PDF</th>
            <th>Edit</th>
            <th>Delete</th>
            <th>Quotation</th>

          </tr>
        </thead>
        <?php
        if($total_rows > 0)
        {
          foreach($all_result as $row)
          {
              
            echo   "<tr>";
            echo   " <td>".$row["order_no"]."</td>";
            echo   " <td>".$row["order_datetime"]."</td>";
            echo   "<td>".$row["project_name"]."</td>";
            echo   "<td>" .$row["project_no"]. "</td>";
            echo   "<td>".$row["the_sector"]."</td>";
            echo   "<td>".$row["order_receiver_name"]."</td>";
            echo "<td>".$row["order_receiver_mobile"]."</td>";
            echo   "<td>".$row["order_total_after_tax"]."</td>";
            echo   "<td>";
            echo '<a href="print_invoice2.php?pdf=1&id='.$row["order_id"].'" target="_blank">PDF</a>';
            echo  "</td>";
            echo  "<td>";
            echo '<a href="cost.php?update=1&id='.$row["order_id"].'"><span class="glyphicon glyphicon-edit"></span></a>';
           echo "</td>";
           echo  "<td>";
           echo '<a href="#" id="'.$row["order_id"].'" class="delete"><span class="glyphicon glyphicon-remove"></span></a>';
           echo "</td>";
           echo "<td >";
           echo '<form onsubmit="onSubmit()" id="frm" method="post"  action="cost.php?updateQuot=1&id='.$row["order_id"].'" >';
           
            echo  '<input type="submit"  value="+" id="submitt" style="margin-left: 50px;"   class="btn_submit'.$row["order_id"].' glyphicon glyphicon-plus"
              >       
              ';

             echo "</form>";

               echo " </td>";

              echo "</tr>";
        

          }
        }
        ?>
      </table>      
     <script>
      
    <?php
    echo "var jsvar ='$abc';";
   ?>
  console.log(jsvar);
   
  function onSubmit() {
   $('.btn_submit'+jsvar).attr('disabled', true);
  }

 </script>
      <?php
      }
      ?>

I want a way to when click on input submit to make the JS take this value btn_submit'.$row["order_id"].

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.