javascript - How to get value text as result for result button after clicking Show button? -


i'm here ask question regarding javascript. i'm new javascript please forgive if i'm going wrong. me values result. after select state drop down list, show button should give me value of states result. possible?

  <h1>please select state</h1>      <select id = "district">     <option value = "tiruvanandapuram">kerala</option>     <option value = "chennai">tamil nadu</option>     <option value = "new delhi">delhi</option>    </select>        <input type = "button" value = "show" onclick = "" />    <input type="text" id="add"  id="txtresult" name="result" value="">      

`

this it:

var sel = document.getelementbyid("district");    function show(){    var txt = document.getelementbyid("add");    txt.value = sel.options[sel.selectedindex].value;  }
<h1>please select state</h1>      <select id = "district">     <option value = "kerala">kerala</option>     <option value = "chennai">tamil nadu</option>     <option value = "new delhi">delhi</option>    </select>        <input type = "button" value = "show" onclick = "show()" />    <input type="text" id="add"  id="txtresult" name="result" value="">


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -