按下按钮时显示ID

时间:2013-04-29 16:21:42

标签: php

<div class="colx2-left align-center">
                        <?php echo Form::button('create-ncn', 'Create NCN', array('class' => 'small-button', 'id' => 'create-ncn', 'type' => 'button', 'value' => 'create-ncn')) ?>
                    </div>

当我按下上面的按钮时,我会将另一个表单填充到我当前正在使用的表格

    public function action_create_yimyan()
{
    $this->template = NULL;
    $this->auto_render = FALSE;

    $id = $this->request->param('id');
    $comp = ORM::factory('Comp', $id);
    $comp->ncn_id = $ncn->id;

    $ncn = ORM::factory('NCN');
    $ncn->user_id = Auth::instance()->get_user()->id;
    $ncn->actionee_id = NULL;
    $ncn->ncn_problem_type_id = 6;
    $ncn->status_id = Status::lookup('In Progress', 'ncn');
    $ncn->department_id = Auth::instance()->get_user()->department_id;
    $ncn->title = $comp->description;
    $ncn->customer = $comp->customer;
    $ncn->dt_logged = time();
    $ncn->save();   
}

我想回显一下ncn_id的id,它是按钮旁边“Comp”表中的一个字段,按下Create NCN按钮时会出现该字段。

Comp表中的ncn_id字段不记录

干杯

1 个答案:

答案 0 :(得分:0)

PHP已经加载后无法动态更改页面。按下按钮后,您可以使用JQuery打印ID号。只需设置占位符并使用jQuery text()函数。 http://www.w3schools.com/jquery/html_text.asp

您可以使用JQuery click()函数查看按钮单击。 http://api.jquery.com/click/