function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } return xmlHttp; } function DueDatePonderado() { var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { DueDatePonderadoHandleResponse(xmlHttp.responseText); } } var form = document.adminForm; var PRIORITYObj = form.id_priority ; // o indice da prioridade para agarrar o tempo var SUPPORTUSERObj = form.assign_to ; // o indice do utilizador de support para verificar-mos o horário e férias var WORKGROUPObj = form.id_workgroup ; // o indice do ticket (para obtermos o departamento, etc....) var TICKETObj = form.ticketmask ; // o indice do ticket (para obtermos o departamento, etc....) var id_priority = PRIORITYObj.value; var id_supportuser = SUPPORTUSERObj.value; var id_workgroup = WORKGROUPObj.value; xmlHttp.open("GET", "http://nvctraining.com/1A/components/com_maqmahelpdesk/js/ajax_duedate.php?p="+id_priority+"&s="+id_supportuser+"&w="+id_workgroup, true); xmlHttp.send(null); } function DueDatePonderadoHandleResponse(response) { //document.getElementById('ResponseDiv').innerHTML = response; /* pegar na resposta e partir em dois para distribuir em data e hora */ //document.getElementById('duedate_date').value = response; devolve algo como 2008-10-10 23:00:00 var due=response.split(" "); // caixa de texto da data: duedate_date document.getElementById('duedate_date').value = due[0]; // caixa de selecção das horas: duedate_hours document.getElementById('duedate_hours').value = due[1]; // backoffice // document.getElementById('duedate_hour').value = due[1]; // frontend }