使用drupal显示用户列表中所选用户的详细信息

时间:2018-06-18 11:25:22

标签: javascript php html drupal

我需要显示所选用户的详细信息。我已完成以下代码但显示所有用户的详细信息单击按钮

使用以下代码创建按钮:

$form['button']['button_' . $result->full_name]= array(
    '#type' => 'button',    
    '#value' => $result->full_name,
    //'#executes_submit_callback' => TRUE,
    '#attributes' => array('onclick' => 'javascript: table("login")'),
    //  '#attributes' => array('onclick' =>"table('login');"),
);

并使用以下方式创建表:

$form['table'] = array(
    '#theme'=>'table',
    '#prefix' => '<div id="login" style="display:none;">',
    '#suffix'=> '</div>',
    '#header'=>$header,
    '#rows'=>$rows,
);

其中$ rows的值为:

$rows[] = array(
    'sn_no' => $i,
    //'full_name' => $result->full_name,    
    'user_name' => $result->user_name,
    'role' => $result->user_group,
    'mobile' => $result->mobile,
    'email' => $result->email,
    // 'actions' => $manage_sid,    
    'actions' => "<a href='$base_url/?q=sf_user/edit_user/" . $result->user_id . "' style='margin-right: 6px;'><img src='$base_url/sites/default/files/images/edit.png' width='16' height='16'></a>
         <span onclick ='' data-toggle='modal' data-target='#myModal_" . $result->user_id . "' style='margin-right: 6px;'><img src='$base_url/sites/default/files/images/delete.png' width='16' height='16'></span>
             <a href='$base_url/?q=sf_user/view_user/" . $result->user_id . "' style='margin-right: 6px;'><img src='$base_url/sites/default/files/images/view.png' width='16' height='16'></a>
            <div class='modal fade' id='myModal_" . $result->user_id . "' role='dialog'>
                <div class='modal-dialog'>
                    <!-- Modal content-->
                    <div class='modal-content'>
                        <div class='modal-header'>
                            <button type='button' class='close' data-dismiss='modal'>&times;</button>
                        <h4 class='modal-title'>Delete  User</h4>
                        </div>
                        <div class='modal-body'>
                            <p>Are you sure you want to delete the SFA User " . $result->full_name . "?</p>
                        </div>
                        <div class='modal-footer'>
                            <button type='button' class='btn btn-default' onclick='delete_user(" . $result->user_id . ");' data-dismiss='modal'>Ok</button>
                            <button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
                        </div>
                    </div>
                </div>
            </div>
           ",
);

javascript代码是:

function table(id){
    var x =document.getElementById('login').rowIndex;
    if (x.style.display === "none") {
        x.style.display = "block";  
    } else {
        x.style.display = "none";
    }
}

0 个答案:

没有答案