Get Combo Label using javascript

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <script type="text/javascript">
        function dispComboText(cmb){
            document.getElementById('valValue').value = cmb.value;
            document.getElementById('valText').value = cmb.options[cmb.selectedIndex].text;
        }
    </script>
  </head>
  <body>
      <select id="test" onchange="dispComboText(this)">
          <option value="1">A</option>
          <option value="2">B</option>
          <option value="3">C</option>
      </select>
      Value : <input type="text" id="valValue"/>
      Text : <input type="text" id="valText"/>
  </body>
</html>
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s