• I’m having trouble moving my PHP-based site to WordPress. One of the main pages I use is a drop down menu of university names, and when you select a school it displays a form below to update that school’s information. However, the onchange() function is not working. The page calls a javascript file to pull up the data as follows:

    function getstatus()
    {
    	var pos = document.getElementById('sform');
    	var value = document.upstatus.sid.options[document.upstatus.sid.selectedIndex].value;
    	pos.innerHTML = 'Loading...';
    	var http = getXMLHTTP();
    	http.open('get', 'https://www.nacurh.org/wordpress/get-status-both/?type=school&sid=' + value);
    	http.onreadystatechange = function()
    	{
    		if (http.readyState == 4 && http.status == 200)
    		{
    			pos.innerHTML = http.responseText;
    		}
    	}
    	http.send(null);
    }
    
    function getystatus()
    {
    	var pos = document.getElementById('sform');
    	var yvalue = document.upstatus.year.options[document.upstatus.year.selectedIndex].value;
    	var value = document.upstatus.sid.options[document.upstatus.sid.selectedIndex].value;
    	pos.innerHTML = 'Loading...';
    	var http = getXMLHTTP();
    	http.open('get', 'https://www.nacurh.org/wordpress/get-status-both/?type=year&sid=' + value + '&year=' + yvalue);
    	http.onreadystatechange = function()
    	{
    		if (http.readyState == 4 && http.status == 200)
    		{
    			pos.innerHTML = http.responseText;
    		}
    	}
    	http.send(null);
    }

    IE is telling me line 6 character 2 “object expected”. I’m not sure what that means. In my <select> tag in wordpress I have it as follows:

    <select name="sid" onchange="getstatus()">

    HELP!

  • The topic ‘Trouble with onchange javascript function’ is closed to new replies.