submit按钮未提交正确的行

dgiusagp  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(176)

我在foreach循环中有一个表单,它显示特定作业的信息,并允许您更新该信息。foreach循环中的每一行都有一个submit按钮,但是submit按钮只在我尝试调整上一个作业的信息时起作用。如果我试图更新任何其他工作的信息,它不会起任何作用。希望这是有意义的,但如果不是我会添加一个图像。

我的代码如下:

<form method="POST" enctype="multipart/form-data">
    <div style="margin-left: 20px;"><h2><a style="color: #fa236a;" href="traveler_profile.php?id=<?php echo $enc ?>"><?php echo $array[0]['name']?> <?php echo $traveler[0]['last_name']?></a> has applied to:<a href="javascript:void(0);" onclick="myFunction(<?php echo $array[0]['id'];?>)"><i class="fa fa-caret-down" aria-hidden="true"></i></a></h2></div>
    <div id="myDIV<?php echo $array[0]['id'];?>" style="display: none;">
        <?php
            foreach($array as $key){
        ?>

        <h3 class="row" style="margin-left: 5%; font-size: 20px;"><strong><?php echo '&nbsp;',$key['discipline'], '&nbsp;' ?></strong> Needed in <strong><?php echo '&nbsp;',$key['settings'],'&nbsp;' ?> </strong><strong>Job Code: </strong><a style="color:#fb236a; text-decoration: underline;" href="https://thelistjobs.com/the_list/job_single.php?id=<?php echo $key['job_code']; ?>"><?php echo '&nbsp;',$key['job_code'],'&nbsp;' ?></a><a href="javascript:void(0);" onclick="myFunction(<?php echo $key['job_code'];?>)"><i class="fa fa-caret-down" aria-hidden="true"></i></a></h3>
        <p class="row" style="margin-left: 5%; font-size: 14px;"><strong>Time: </strong><?php echo '&nbsp;',$startTimeTwo,'&nbsp;' ?><strong>Date:</strong> <?php echo '&nbsp;',$startDate ?></p>
        <?php

            $traveler_info = "SELECT * FROM ".TABLEPRIFIX."traveler WHERE traveler_id =".$array[0]['traveler_id'];
            $traveler = $obj->queryResult($traveler_info);
        ?>

        <!-- contracts Begin -->
        <div id="myDIV<?php echo $key['job_code']; ?>" style="display: none;">
            <input style="display: none;" value="<?php echo $key['id'] ?>" name="id">
            <input style="display: none;" value="<?php echo $key['traveler_id'] ?>" name="traveler_id">
            <input style="display: none;" value="<?php echo $traveler[0]['name'] ?> <?php echo $traveler[0]['last_name'] ?>" name="name">
            <input style="display: none;" value="<?php echo $_SESSION['userall_id'] ?>" name="agent_id">

            <div class="row" style="margin-left: 5%; width: 90%;">
                <div class="col-2" style="text-align: center;">
                    <p style="text-align: center;">Submitted</p>
                    <input style="text-align: center; position: static; opacity: 1; z-index: 1;" type="checkbox" checked>
                </div>
                <div class="col-2" style="text-align: center;">
                    <p style="text-align: center;">Accepted</p>
                    <input style="text-align: center; position: static; opacity: 1; z-index: 1;" value="No" name="on_assignment" type="hidden">
                    <input style="text-align: center; position: static; opacity: 1; z-index: 1;" value="Yes" name="on_assignment" type="checkbox" <?php if($key['on_assignment'] == 'Yes') {echo 'checked'; } else {} ?>>
                </div>
                <div class="col-3" style="text-align: center;">
                    <p style="text-align: center;">Start</p>
                    <input type="date" style="width: 80%;" value="<?php echo $key['start_date'] ?>" name="start_date">
                </div>
                <div class="col-3" style="text-align: center;">
                    <p style="text-align: center;">End</p>
                    <input type="date" style="width: 80%;" value="<?php echo $key['end_date'] ?>" name="end_date">
                </div>
                <div class="col-2">
                    <button name="" value="update" formaction="response/recruiter_add_contract.php" style="align: center; margin-left: 30px; float: left; font-size: 12px; padding: 10px 20px; border-radius: 25px; background-color: #fa236a;">Submit</button>
                    <a  style="font-size: .75rem;" href="response/recruiter_add_contract.php?jobId=<?php echo $key['id'] ?>&status=0" class="btn btn-warning">Declined</a>
                </div>
            </div>
        </div>
        <!-- Contracts End -->
        <?php
            }

        ?>

        <div class="row" style="width: 90%;">
            <div class="col-12">
                <button class="row" name="" value="archive" formaction="response/bad_traveler_process.php" style="font-size: 12px; float: left; padding: 10px; border-radius: 25px; background-color: #ffc107; margin-left: 5%;">Archive Traveler</button>
            </div>
        </div>

   </form>

我查看了其他堆栈文章,并尝试了多种调整,例如添加onclick()或onsubmit(),尝试了将按钮更改为输入,尝试了将特定作业id添加到submit按钮,以及各种其他方法。没有什么是我的工作,所以我希望有人可能有一个想法的东西,尝试或研究的方法,可能会得到我的问题解决。事先谢谢你的建议。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题