Web Analytics Made Easy -
StatCounter Running a function from Listbox 'onchange' - CodingForum

Announcement

Collapse
No announcement yet.

Running a function from Listbox 'onchange'

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running a function from Listbox 'onchange'

    Hi there, this seems extremely simple but for some reason I can't see the problem with it.....maybe a fresh pair of eyes will help! I have the following javascript function and listbox:

    Code:
    <script type="text/javascript">
    function IntOrExt()
    {
    	if (document.FormName.IntOrExt.Value == "Int")
    	{
    	document.FormName.SecondaryExtRangeFrom.disabled=false;
    	document.FormName.SecondaryExtRangeTo.disabled=false;
    	}
    	else
    	{
    	document.FormName.SecondaryExtRangeFrom.disabled=true;
    	document.FormName.SecondaryExtRangeTo.disabled=true;
    	}
    }
    </script>
    
    
    
    <select name="IntOrExt" id="IntOrExt" style="width:188px" onchange="IntOrExt()">
    
              <option selected="selected" value="Ext">External Numbers</option>
              <option value="Int">Internal Number Range</option>
    
            </select>
    When I change the value of the listbox I get the error:

    "Error: Object doesn't support this property or method"

    Any ideas why?!

    Thanks

  • #2
    ah.....I've done it now......I used the following code instead:

    Code:
    <script type="text/javascript">
    
    function setIntOrExt(val)
    {
    	if (val == "Int")
    	{
    	document.FormName.SecondaryExtRangeFrom.disabled=false;
    	document.FormName.SecondaryExtRangeTo.disabled=false;
    	}
    	else
    	{
    	document.FormName.SecondaryExtRangeFrom.disabled=true;
    	document.FormName.SecondaryExtRangeTo.disabled=true;
    	}
    }
    </script>
    
    
    <select name="IntOrExt" id="IntOrExt" style="width:188px" onchange="setIntOrExt(this.value);">
              <option selected="selected" value="Ext">External Numbers</option>
              <option value="Int">Internal Number Range</option>
            </select>

    Comment

    Working...
    X