Thursday 15 March 2012

Javascript/HTML error “the value of the property “selectReason” is null or undefined, not a function object -



Javascript/HTML error “the value of the property “selectReason” is null or undefined, not a function object -

hi new javascript , html , wondering if help me understand why error keeps occuring. basic thought have dropdownlist populated several options. when client selects alternative onchange event fires write value of selected alternative textarea. when debug message above have included relevant snippets of code below:

function selectreason() { var selectindex = document.getelementbyid("selectmessage").selectedindex; var selecttext = document.getelementbyid("selectmessage").value; document.getelementbyid("txt").value = selecttxt; } <tr style="display: none; visibility: hidden" id=sel> <td width="60%" align=left>please select reason</td> <td width="40%" align=left> <select id="selectmessage" onchange="selectreason()" style="width: 425px"></select> </td> </tr>

maybe help you

<html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> </head> <body> <table> <tbody> <tr> <td> <select name="" id="selectmessage"> <option value="red">red</option> <option value="gree">green</option> <option value="blue">blue</option> </select> </td> </tr> </tbody> </table> <textarea name="" id="txt" cols="30" rows="10"> </textarea> <script type="text/javascript"> $(document).on('ready', function(){ $('#selectmessage').on('change', function(){ var val = $(this).val(); var txt = $('#txt'); txt.val(val); }); }); </script> </body> </html>

hope :)

javascript html

No comments:

Post a Comment