ciao a tutti,
sto facendo qualche esperimento in ajax utilizzando la libreria moo.ajax.
ho creato questo script sbirciando anche la guida di Prototype. Funziona benissimo solo che il validatore W3C mi segnala diversi errori. In particolare riguardo l'attributo "name" del form...e la chiamata della function sull'On Change della select...come posso mantenere la funzionalità dello script e al tempo stesso avere una pagina senza errori a livello di xhtml?
ecco gli errori:
# Line 31 column 29: required attribute "action" not specified.
<form name="prova" id="prova">
✉
# Error Line 32 column 70: document type does not allow element "select" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" start-tag.
...ees" id="lstEmployees" onchange="searchSales()">
ecco la pagina:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="robots" content="all" />
<title>prova</title>
<script type="text/javascript" src="prototype.lite.js"></script>
<script type="text/javascript" src="moo.ajax.js"></script>
<script>
function searchSales() {
var empID = document.prova.lstEmployees.options[document.prova.lstEmployees.selectedIndex].value;
//var y = 'lstYears';
var url = 'ajaxteam2.asp';
var pars = 'team=' + empID;
new ajax (
url,
{postBody: pars, update: $('result'), onComplete: showResponse}
);
}
function showResponse(request) {
//put returned XML in the textarea
$('result').value = request.responseText;
}
</script>
</head>
<body>
<form name="prova" id="prova">
<select name="lstEmployees" id="lstEmployees" onchange="searchSales()">
<option value="4">UNO</option>
<option value="3">DUE</option>
<option value="1">tre</option>
</select>
</form>
<div id="result">
questo testo sarà sostituito dal contenuto restituito dalla pagina asp.
</div>
</body></html>