javascript - 我们如何将文本框值设置为下拉列表?

标签 javascript jquery

 function SetUtcTimeZone() {
     var UTCTimeZone = document.getElementById("txtPortorAnchorDeparture").value;
     document.getElementById('ddlUTCTimeZone').selectedIndex = UTCTimeZone;
 }
<小时/>

如何使用 dropdownlist id 将文本框值设置为 dropdownlist

最佳答案

我想它看起来像这样:

function SetTxt() {
     var indx = document.getElementById('ddlUTCTimeZone').selectedIndex;
     var val  = document.getElementById('ddlUTCTimeZone').options[indx].text;
     document.getElementById("txtPortorAnchorDeparture").value = val;
}

关于javascript - 我们如何将文本框值设置为下拉列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42873608/

相关文章:

javascript - 检查包含对象作为数组的数组中的重复项

javascript - 更新后 react 18 Paypal 按钮显示两次

jquery - 如何在窗口卸载时发送 AJAX 请求而不需要等待响应

javascript - 在嵌入链接中显示上传的 PDF

Javascript改变图像颜色IndexSizeError : Index or size is negative or greater than the allowed amount

javascript - 树布局 - 链接 - 数据格式

javascript - 在 JavaScript 中从文本创建类

javascript - 为什么使用 jQuery 缓存 AJAX?

php - jquery $.post 从 php 返回的数据为空

javascript - 在每次 href 出现之前放置文本?