Ciao a tutti, vi scrivo perchè ho un problema a recuperare i valori delle checkbox in javascript, precisamente in una chiamata ajax:
il mio form è questo:
e il mio codice javascript écodice:<form name="form_mappa" id="form_mappa" method="GET"> <input type="checkbox" name="oggi" value="oggi">Oggi</input> <input type="checkbox" name="balli" checked="checked" value="balli">Balli</input> </form>
ma mi manca una funzione da richiamare per recuperare i valori dei checkbox.codice:function showData(){ xmlhttp=GetXmlHttpObject(); if (xmlhttp==null){ alert ("Browser does not support HTTP Request"); return; } var url="Live.php"; url=url+"?oggi="+oggi+""; xmlhttp.onreadystatechange=stateChanged_check; xmlhttp.open("GET",url,true); xmlhttp.send(null); if (xmlhttp.readyState==4){ document.getElementById("prova_check").innerHTML=xmlhttp.responseText; } } function stateChanged_check(){ if (xmlhttp.readyState==4){ document.getElementById("info_check").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject(){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject){ // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; }
Per recuperare il valore di un input avevo utilizzato:
per i checkbox invece come si fa?codice:var data_ajax = document.nomeForm.nomeInput.value;
Grazie mille
Stefania

Rispondi quotando
