提交表单后更改提交按钮的值

时间:2017-03-19 18:45:43

标签: php html5

在我的页面中存在许多提交按钮,这些按钮是根据我表格中的记录创建的

我需要的是当我按下立即申请按钮时,我需要将其更改为已应用每次我点击它提交表单的按钮

  <form action="" method="POST">
      <?php 
      include('conn.php');
      $i=0;
      $rs=mysqli_query($con,"select * from post_job");

      while($arr=mysqli_fetch_row($rs))
      {
          $i++;
      ${'job_id' . $i} = $arr[0];
      ${'company_id' . $i} = $arr[1];

   echo '<div class="tab_grid">';
   echo '<div class="jobs-item with-thumb">';
   echo   "<div class='thumb'><a href='#'><img src='company/$arr[9].jpg' class='img-responsive' alt=''/></a></div>";
   echo '<div class="jobs_right">';
    echo    "<div class='date'><span>$arr[10]</span></div>";              
    echo    "<div class='date_desc'><h6 class='title'><a href='#'>$arr[2]</a></h6>";
    echo  "<span class='meta'>$arr[7]</span>";
    echo "</div>";
    echo    "<div class='clearfix'> </div>";
    echo "<ul class='top-btns'>";
    echo    "<li><a href='#' class='fa fa-plus toggle'></a></li>";
    echo    "<li><a href='#' class='fa fa-star'></a></li>";
    echo    "<li><a href='#' class='fa fa-link'></a></li>";
    echo    "</ul>";
    echo    "<p class='description'>$arr[3]</a></p>";
echo '<input type="button" name="submit'.$i.'"  id="sbtid'.$i.'" value="Apply Now"  required="required" class="btn btn-default pull-left" onclick="return changeText("sbtn");" >';
    echo    "</div>";
    echo    "<div class='clearfix'> </div>";
    echo    "</div>";
    echo    "</div>";

      }
      ?>
    </form>

    <?php
        for($j=1;$j<=$i;$j++)
        {
            if(isset($_POST['submit'.$j]))
            {

    include('conn.php');
    mysqli_query($con,"insert into job_applied values(DEFAULT,'${'job_id'.$j}','${'company_id'.$j}','$id')");
            }

        }
    ?>

0 个答案:

没有答案