Skip to Content
author's profile photo
Former Member

javascript and drowdownlist in DynPage

Hello,

How could I get a selected value from a dropdownlist in a JavaScript function ? For InputField work it, but unfortunately not for dropdownlist.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    author's profile photo
    Former Member
    Aug 13, 2004 at 08:12 PM

    Hi,

    Here's an example on how you can get the selected value via javascript.

    Hope it helps.

    Regards,

    Leif

    <html>

    <head>

    <script language="JavaScript">

    function showValue(selObj){

    alert(selObj.options[selObj.selectedIndex].value);

    }

    </script>

    </head>

    <body>

    <form name="myForm">

    <select name="sample" size="1" onChange="javascript:showValue(this);">

    <option value="One">First</option>

    <option value="Two">Second</option>

    <option value="Three">Third</option>

    </select>

    </form>

    </body>

    </html>

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 13, 2004 at 08:18 PM

    Hi,

    One small warning, accessing HTML in the browser is fine if you rendered the HTML yourself. But be careful when you are using our HTMLB libraries. From time to time the HTML changes, or if you switch from Design2002 to Design2003, it could be that the HTML is changed to much and might break your JavaScript code. Just keep this in mind.

    The answer from Leif is perfectly correct. Please do not forget the rules of engagement (posted in this forum), and to press the yellow star to give what is owed.

    ++bcm

    Add comment
    10|10000 characters needed characters exceeded