var thisName=''; var thisSurname=''; var thisYoC=''; var thisArea=''; var updateName = function (e) { nameSelector = document.getElementById("name"); thisName = nameSelector.value; renderListing(); } var updateSurname = function (e) { surnameSelector = document.getElementById("surname"); thisSurname = surnameSelector.value; renderListing(); } var updateYoC = function (e) { yoCSelector = document.getElementById("yearofcall"); thisYoC = yoCSelector.value; renderListing(); } var updateArea = function (e) { areaSelector = document.getElementById("practicearea"); thisArea = areaSelector.value; renderListing(); } function renderListing(){ document.getElementById('lawyerListing').innerHTML = '
'; // Get the htmlCode using Yahoo! library connection util setTimeout(getNewContent,250); } function getNewContent() { var embedURL = 'http://www.wildlaw.ca/resources/elements/lawyerListing.jsp?name='+thisName+'&surname='+thisSurname+'&yearofcall='+thisYoC+'&practicearea='+thisArea; var htmlCode = YAHOO.util.Connect.asyncRequest('POST', embedURL, parseListing); } var parseListing = { success: drawListing, failure: errorListing } function drawListing(obj){ var htmlCode = obj.responseText; document.getElementById('lawyerListing').innerHTML = htmlCode; } function errorListing(obj){ // Handle error var htmlCode = obj.responseText; document.getElementById('lawyerListing').innerHTML = htmlCode; } YAHOO.util.Event.addListener("name", "change", updateName); YAHOO.util.Event.addListener("surname", "change", updateSurname); YAHOO.util.Event.addListener("yearofcall", "change", updateYoC); YAHOO.util.Event.addListener("practicearea", "change", updateArea);