この関数を使用して、フォームで選択した値を表示しています。結果は私のページに正しく表示されていますが、getlist.phpページには何も送信されません。
誰か助けてくれませんか?
Jqueryコード:
function showValues() {
var str = $("form").serialize();
$("#results").text(str);
}
$(":checkbox, :radio").click(showValues);
$("select").change(showValues);
showValues();
$.post("getlist.php", $("form").serialize());
HTML:
<p><tt id="results"></tt></p>
これが私のフォームです
<form id="Moteur" onchange="testMoteur()">
<table cellspacing="0" cellpadding="5" bgcolor="#Be9e55">
<tr height="30px">
<td align="right">Marques : </td>
<td><? include ("marques.php"); ?></td>
</tr>
</table>
</form>
およびmarques.phpコード
<select name="marques" id="marques" multiple="multiple">
<?
//<option value="x">Toutes les marques :</option>
?>
<?
mysql_connect("","","");
mysql_select_db("");
$query = mysql_query("SELECT * FROM marque WHERE flag_montre=1 ORDER BY nom ASC");
while ($myrow = mysql_fetch_row($query)) {
$id_marque=$myrow[0];
//test si marque est vide
$res3=mysql_query("SELECT * FROM montre WHERE id_marque=$id_marque AND id_etat=3");
$nbreLignes = mysql_num_rows($res3);
if ($nbreLignes==0){
}
else {
echo "<option value='".$myrow[0]."'>".$myrow[1]." (".$nbreLignes.")</option>";
}
}
?>
</select>
スクリプトを更新しました。Firefoxではすべて正常に動作していますが、ie8では何も起こりません(0エラー)。このスクリプトの目的は、配列内の変数をgetlist.phpに送信することです。
function SendMoteur() {
var xmlhttp = "";
var url = "";
// For modern browsers
if(window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
// for IE 5/6
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
// Rebuild the array of selected option boxes
marques = document.getElementById("marques");
for(var i=0; i < marques.length; i++) {
if(marques[i].selected) {
// Note the [] after the name
url += "&marques[]=" + marques[i].value;
}
}
fourchettes = document.getElementById("fourchettes");
for(var i=0; i < fourchettes.length; i++) {
if(fourchettes[i].selected) {
// Note the [] after the name
url += "&fourchettes[]=" + fourchettes[i].value;
}
}
mouvements = document.getElementById("mouvements");
for(var i=0; i < mouvements.length; i++) {
if(mouvements[i].selected) {
// Note the [] after the name
url += "&mouvements[]=" + mouvements[i].value;
}
}
boitiers = document.getElementById("boitiers");
for(var i=0; i < boitiers.length; i++) {
if(boitiers[i].selected) {
// Note the [] after the name
url += "&boitiers[]=" + boitiers[i].value;
}
}
bracelets = document.getElementById("bracelets");
for(var i=0; i < bracelets.length; i++) {
if(bracelets[i].selected) {
// Note the [] after the name
url += "&bracelets[]=" + bracelets[i].value;
}
}
xmlhttp.open("GET","getlist.php?" + url, false);
xmlhttp.send();
if (xmlhttp.status == 200) {
document.getElementById("txtHint2").innerHTML = xmlhttp.responseText;
} else {
return false;
}
return false;
}
</script>