如何使用PHP計數器通過javaScript顯示隱藏文本字段。我有這樣的代碼在HTML成立的PHP:單擊按鈕時顯示隱藏對象(PHP with javaScript)
<?php if(isset($prior)): foreach($prior as $row): ?>
<tr>
<td> <?php echo $row->priority?> </td>
<td> <?php echo $row->priority_time?> </td>
<td>
<button type="button" class="btn btn-info btn-sm" onclick="">
<span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
</button>
<input type="text" id="" name="<?php echo $row->priority_id?>" hidden/>
</td>
</tr>
<?php endforeach;?>
<?php else:?>
<p>Request Service not available</p>
<?php endif;?>
如何在javaScript中添加php代碼? – Char
您並未向JS添加PHP代碼。您正在向該頁面添加一個名爲'showField'的JS函數,並使用PHP將'name'參數添加到在'button'的'onclick'內調用的函數中。 – Enijar