【问题标题】:Make the value from option select auto-entered to the textarea使选项选择中的值自动输入到文本区域
【发布时间】:2022-02-11 14:17:23
【问题描述】:

有什么方法可以将 select 选项中的值自动插入到 textarea 中? (在 php 中)

选项选择:

<select id="Branch">
  <option value="MCG">MCG</option>
  <option value="KB">KB</option>
  <option value="KT">KT</option>
</select>

文本区域

<input name="street" type=text value=>

如果我没有正确提问,请提前道歉

【问题讨论】:

标签: php html


【解决方案1】:

在更改选择时不能一次使用 PHP,但是, 您可以选择使用 javascript 之类的打击示例自动插入到文本区域的选项

function updateTextareaValue(selectVal){
      document.getElementById("street").value = selectVal;   
}
<html>
    <body>
        <select id="Branch" onchange="updateTextareaValue(this.value);">
            <option value="MCG">MCG</option>
            <option value="KB">KB</option>
            <option value="KT">KT</option>
            <option value="XX">XX</option>
            <option value="YY">YY</option>
        </select>       
        <textarea id="street"></textarea>        
    </body>
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    相关资源
    最近更新 更多