onchange not calling java function

Discussion in 'JavaScript' started by Bostad, Aug 30, 2011.

  1. #1
    Hi;

    I had an onchange event calling a function perfectly this morning. I changed something, but can't remember what, and now it's broken.

    This is the code:

    
    tr><td><div id="HexCForm"><form name="HexCalc">
     Select: <select id="Selection" onchange="Checking()">
    <option>*</option>
    <option value="SourceName">SourceName</option>
    <option value="DestName">DestName</option>
    </select><br>
    
    <div id="HCFSearch">
    
    </div>
    
    
    
    </td></tr></form>
    
    Code (markup):
    The Checking function is just a document.write to check. There is an AJAX call to a PHP script that is normally in place
     
    Bostad, Aug 30, 2011 IP
  2. iBank ™

    iBank ™ Peon

    Messages:
    63
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    0
    #2
    The given part of your code works just fine for me. Are you sure Checking() function exists ?
     
    iBank ™, Aug 31, 2011 IP
  3. Bostad

    Bostad Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi;

    Weird....here is the scripts portion of my page. Initially (the bit that worked was LoadHexForm(str) )

    
    <script type="text/javascript" >
    function FullCLog()    {
        xmlhttp=new XMLHttpRequest();
        
        xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("GoBtn").innerHTML=xmlhttp.responseText;
        }
      }
      
        xmlhttp.open("GET","fullquery.php",true);
        xmlhttp.send();
    }
    
    function HexQuery()   {
    
            xmlhttp.onreadystatechange=function()
            document.write('Start');
            stop()
                            
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("HexButton").innerHTML=xmlhttp.responseText;
        }
      }
      
        xmlhttp.open("GET","hexquery.php?q="+chkd,true);
        xmlhttp.send();
        document.write("HexQuery Ends")
    }
    
    function Checking() {
    
    document.write("Checking Hit")
    
    }
      
    }
    function GetHex(str)   {
    
            xmlhttp.onreadystatechange=function()
                            
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("HexVals").innerHTML=xmlhttp.responseText;
        }
      }
      
        xmlhttp.open("GET","gethex.php?q="+str,true);
        xmlhttp.send();
    }
    
    function LoadHexForm(str)  {
    
    xmlhttp=new XMLHttpRequest();
        
        xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("HCFSearch").innerHTML=xmlhttp.responseText;
        }
      }
       xmlhttp.open("GET","loadlist.php?q="+str,true);
      xmlhttp.send();
      
      }
    </script>
    
    Code (markup):
    The complete section the bit that's not working is in is:

    
    <table border="1" cellpadding="1" cellspacing="1" align="center">
    <tr><td><center><b>Unit Search and Hex Mask Calculator</b></center></td></tr>
    <tr><td><div id="HexCForm"><form name="HexCalc">
     Select: <select id="Selection" onchange="Checking()">
    <option>*</option>
    <option value="SourceName">SourceName</option>
    <option value="DestName">DestName</option>
    </select><br>
    
    <div id="HCFSearch">
    
    </div>
    
    
    
    </td></tr></form>
    
    Code (markup):
    Thanks for looking at this
     
    Bostad, Aug 31, 2011 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    You still didn't post the code for the function named Checking.

    onchange="Checking()" says that there is a function with that name, and that's what runs when Selection gets changed.
     
    Rukbat, Aug 31, 2011 IP
  5. Bostad

    Bostad Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi;

    Its there, buried in the script tags...

    but here it is broken out.

    
    
    function Checking() {  document.write("Checking Hit") 
    }
    
    Code (markup):
     
    Last edited: Aug 31, 2011
    Bostad, Aug 31, 2011 IP