Home > other >  Make the value from option select auto-entered to the textarea
Make the value from option select auto-entered to the textarea

Time:02-10

Is there any way that the value from select option to be auto-inserted into a textarea? (in php)

Option Select:

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

TextArea

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

Sorry in advance if I didn't ask the question correctly

CodePudding user response:

It is not possible using PHP at a time on change select but, You can select option to be auto-inserted into a textarea using javascript like blow example

function updateTextareaValue(selectVal){
      document.getElementById("street").value = selectVal;                                
      console.log(document.getElementById("street").value);                
}
<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>

  •  Tags:  
  • Related