0

SQL データベースからのユーザー情報を表示する HTML テーブルを作成しました。

<table class="table table-hover">
    <tr>
        <th>Username</th>
        <th>Password</th>
        <th>Role</th>>
        <th>Attribute</th>
        </th>
        <th>Ideas/Score</th>
        <th>Edit</th>
        <th>Delete</th>
    </tr>
    <?php while($result=m ysqli_fetch_array($fetch)) { $usertoattrquery="SELECT * FROM usertoattr WHERE usertoattr.user_id=" .$result[user_id]; $attrfetch=mysqli_query($con,$usertoattrquery) or die ( 'could no connect with instructions'); echo "<tr><td>".$result[ "username"]. "</td><td>" .$result[ "password"]. "</td>
    <td>" .$result[ "role"]. "</td><td>only for Eval</td><td>coming soon</td><td>
         <a href='#editUser' role='button'  class='btn' data-toggle='modal'>Edit</a> </td>
         <td><button class='btn'onclick='deleteConfirm()'>Delete</button> </td></tr>"; } ?>
</table>

誰かが特定の行で「編集」ボタンを押すと、モーダルが開かれ、このテーブル行の値がモーダル内にコピーされます (名前やパスワードなど)。

<div id="editUser" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    </div>
     <h3 id="myModalLabel">Edit User</h3>
User Name
    <input type="text">
    <br>User Password
    <input type="text">
    <br>User Role
    <select>
        <option>Evaluator</option>
        <option>Observer</option>
    </select>
    <br>User Attribute
    <select multiple>
        <option>Economics</option>
        <option>Software</option>
        <option>Management</option>
    </select>
    <br>
    <button class='btn btn-primary'>OK</button>
    <button class='btn' data-dismiss="modal" aria-hidden="true">Cancel</button>
</div>

そんなことがあるものか?

4

1 に答える 1

0

それぞれにIDを追加することもできます<td>(それぞれが異なることを確認してください。複数のIDは悪いです!!)

次に、JavaScript でその値 (.innerHTML) を使用して、モーダル内の入力テキストの値を設定します。

于 2013-06-05T02:46:54.173 に答える