簡體   English   中英

使用php以相同的形式將值從下拉列表傳遞到文本框

[英]pass values from drop-down list to textbox in same form using php

我正在嘗試以相同形式從下拉列表中向文本框添加值。 這是我的代碼:

<tr>
    <td>
    <?php
    require_once '../componetsUsed/dbconfig.php';
    $stmt = $db_con->prepare("SELECT * FROM artist ORDER BY art_id DESC");
    $stmt->execute();
    ?>
        <select name='art_id' class='form-control' required>
            <option disabled selected>Select Artist</option>    
            <?php
            while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
            ?>
            <option value="<?php echo $row['art_id']; ?>"><?php echo ucwords(strtolower($row['art_name'])); ?></option>
            <?php
            }
            ?>
        </select>
    </td>
</tr>
<tr>
    <td></td>
    <td>
        <input type='text' name='art_name' class='form-control' value=""/>
    </td>
</tr>

我想將選擇的選項(藝術家姓名)添加到輸入框。 (我可以獲取數據以從數據庫中選擇菜單)。 不使用JavaScript怎么辦?

任何幫助是極大的贊賞!

$("#drp_dwn").change(function () {
    $("#textArea").val(this.value);
 }).change();

還要檢查此演示http://jsfiddle.net/TZQnS/234/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM