// JavaScript Document /* FORM VALIDATION FUNCTION */ function formValidate(frm){ if(frm.opt_abbr.value=='') { alert("Please Enter Option Abbreviation"); frm.opt_abbr.focus(); return false; } else if(frm.opt_abbr.value.length > 16) { alert("Option Abbreviation can be maximum 16 characters long"); frm.opt_abbr.focus(); return false; } else return true; } /* AJAX CALLING FUNCTION FOR POPULATING EDIT */ function editVehOption(id) { if (window.XMLHttpRequest) http_request = new XMLHttpRequest(); else if (window.ActiveXObject) http_request = new ActiveXObject("Microsoft.XMLHTTP"); url ='http://www.reliancemotors.com.na/secure/actions/option.action.php?action=edit&id='+id; // window.open(url); try { http_request.open('GET', url,true); } catch(err){alert(err.toString());} http_request.onreadystatechange = handleResponseVehOption; try { http_request.send(null); } catch(err){alert(err.toString());} } function handleResponseVehOption() { var xmldoc = http_request.responseXML; if(http_request.readyState == 4 ) { if(xmldoc.getElementsByTagName('opt_abbr')[0].hasChildNodes()) document.getElementById("opt_abbr").value = xmldoc.getElementsByTagName('opt_abbr')[0].firstChild.data; if(xmldoc.getElementsByTagName('opt_title')[0].hasChildNodes()) document.getElementById("opt_title").value = xmldoc.getElementsByTagName('opt_title')[0].firstChild.data; if(xmldoc.getElementsByTagName('opt_id')[0].hasChildNodes()) document.getElementById("opt_id").value = xmldoc.getElementsByTagName('opt_id')[0].firstChild.data; document.getElementById("action").value = "update"; document.getElementById("button").value = "Update Vehicle Option"; } }