duanmianhong4893 2019-07-23 06:57
浏览 56
已采纳

是否可以重定向到PHP中的函数内的另一个函数?

I am adding a delete button to certain rows of a table (not all). The table is already inside a form, so my thinking is to do a check to see if my button was clicked inside the function that the form submits to and redirect to a delete function if it was. I can't figure out if it's possible to do that or what other options there are.

I tried using a link for the delete, but that doesn't get the information across. I tried using another form, but that's a form within a form. If there is another way to do this, I'm happy to learn it.

Here is parts of the form:

echo '<form action="#/job/addorupdate" id="jobform" name="jobform" method="post" accept-charset="utf-8">';
    echo '<input type="hidden" name="id" value="228828">';
    if ($id > 0) {
        echo '<button style="color:red;border:none;font-weight:bold;cursor:pointer;" type="submit" value="' . $id . '" name="idOfRow">X</button>';
    }
    echo '</form>';

Here is the function it goes to:

public function addOrUpdate(){ // addOrUpdate a job - control
    if ($this->input->post('idOfRow')) {
        // This is where I want to do the redirect
    }
    .
    .
}
  • 写回答

2条回答 默认 最新

  • doukui2011 2019-07-23 10:12
    关注

    The solution was to replace the button with a link and use that to call the delete function.

    echo '&nbsp;<a href="' . site_url('#/deleteunrelatedcase/' . $jobid . '/' . $id) . '" style="color:red;font-weight:bold;">X</a>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!