亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

onchange 無法獲取正確的值

onchange 無法獲取正確的值

PHP
慕容森 2023-04-02 10:58:34
我在獲取 onchange 函數的輸入值時遇到問題。下面是我的編碼: <div class="form-group"> <label>Choose Book:<span style="color:red;">&nbsp;*</span></label> <select class="form-control" id="publisher" name="publisher" title="publisher"> <option value="">Please Select</option> <?php $sql_branch = 'select * from book_lending where status=1 order by id'; $arr_branch = db_conn_select($sql_branch); foreach ($arr_branch as $rs_branch) { echo '<option value="' . $rs_branch['id'] . '">' . $rs_branch['title'] . '</option>'; } ?></select>  </div> <div class="form-group"> <label for="cp1" class="control-label">Book Stock<span style="color:red;">&nbsp;*</span></label> <input readonly="readonly" type="text" class="form-control" id="editor" name="editor" title="editor" value="" > </div><script>$(function(){    $("#publisher").change(function(){        var displayid=$("#publisher option:selected").text();        $("editor").val(displayid);    })})</script>下面是輸出圖片:如果我在 id is publisher 中 onchange 我需要顯示輸入值,然后 id editor 將顯示該值。希望有人能指導我我弄錯了哪一部分。謝謝。
查看完整描述

2 回答

?
qq_笑_17

TA貢獻1818條經驗 獲得超7個贊

您缺少編輯器 ID


$(function(){

    $("#publisher").change(function(){

        var displayid=$(this).val();

        $("#editor").val(displayid);

    })

})


查看完整回答
反對 回復 2023-04-02
?
泛舟湖上清波郎朗

TA貢獻1818條經驗 獲得超3個贊

嘗試這個:-


<script>

$(function(){

    $("#publisher").change(function(){

        var value=$("#publisher").val();

        $("#editor").val(value);

    })

})

</script>


查看完整回答
反對 回復 2023-04-02
  • 2 回答
  • 0 關注
  • 208 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號