The onchange command wont call my function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcelrob5
    New Member
    • Jun 2010
    • 19

    The onchange command wont call my function

    I think I may have already posted something similar but I cant find it so i will psot it again.

    I have a drop-down selection box on an HTML page and when you select a value in the box that changes the value it should call a function. However it doesn't work and it is driving me nuts because it should be right the way i see it.

    If anyoine sees what I am missing please let me know what it is and how i can fix it.

    Code:
    <script type="text/javascript">
        function getRange(val){
            alert("inside getRange()");
            if(val==2){
                inner="<input id =\"startdate\" type=\"text\"><img src=\"/sslcert-portlet/img/calendar.png\" onclick=\"return showCalendar(\'strtdate\',\'%m/%d/%Y\');\"";
                inner=inner+" To <input id=\"enddate\" type=\"text\"><img src=\"/sslcert-portlet/img/calendar.png\" onclick=\"return showCalendar(\'enddate\', \'%m/%d/%Y\');\"><br /><br /><br />";
                document.getElementById("range").innerHTML=inner;
            }
        }
    </script>
    
    <table>
                <tr><td></td></tr>
                <tr><td>Select Report Type</td></tr>
                <tr><td>
                        <select id="reportType" onchange="getRange(this.selectedIndex);">
                            <option value="0" SELECTED="selected">...</option>
                            <option value="1">45 Day Report</option>
                            <option value="2">Custom...</option>
                        </select>
                    </td></tr>
                <br />
                <tr><td>
                        <span id="range"></span>
                    </td></tr>
            </table>
  • maminx
    New Member
    • Jul 2008
    • 77

    #2
    how about
    onChange = "javascript:get Range(this.sele ctedIndex);"

    Comment

    • mcelrob5
      New Member
      • Jun 2010
      • 19

      #3
      Actually I found that the name 'getRange' was the cause of the problem so I just changed the name toi 'createRange' and it works fine now. But again thank you for your advice.

      Comment

      Working...