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

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -