this.form.submit()选择,只发布一个选项

时间:2016-01-15 11:01:41

标签: javascript php html select option

如果我在循环选择中使用onchange="this.form.submit()"

<form>
<?php
$a=0;
while($a <= 10) {
?>
<select name="lagra" id="lagra" class="drop <?php echo $statusbg; ?>" onchange='this.form.submit()'>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s0; ?> value="<?php echo $val; ?>.1">Åpen</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s1; ?> value="<?php echo $val; ?>.2">Stengd</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s2; ?> value="<?php echo $val; ?>.3">Utskriven</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s3; ?> value="<?php echo $val; ?>.4">Klar/fakt</option>
</select>
<?php
$a++;
}
?>
</form>

我只想发布一个选项?

现在我的查询如下:

index.php?viewtime=yes&ukeID=0&orderID=2&tilleggID=0&status=&lagra=39.2&lagra=42.2&lagra=43.1&lagra=38.1&lagra=28.3&lagra=23.3&lagra=22.3&lagra=27.3&lagra=20.3&lagra=21.3

我不想要所有这些,只有我改变的那个。

index.php?viewtime=yes&ukeID=0&orderID=2&tilleggID=0&status=&lagra=39.2
像上面一样。

1 个答案:

答案 0 :(得分:0)

解决了它。

不是最好的方式,但它有效。 每个选择的新形式。

<form id="form1" name="form1" method="GET" action="">
<select name="lagra" id="lagra" class="drop <?php echo $statusbg; ?>" onchange='this.form.submit()'>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s0; ?> value="<?php echo $val; ?>.1">Åpen</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s1; ?> value="<?php echo $val; ?>.2">Stengd</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s2; ?> value="<?php echo $val; ?>.3">Utskriven</option>
<option class="drop <?php echo $statusbg; ?>" <?php echo $s3; ?> value="<?php echo $val; ?>.4">Klar/fakt</option>
</select>
<?php
if(!empty($_REQUEST['status'])) { $status = $_REQUEST['status']; }
else { $status = ""; }
echo '<input hidden value="'.$orderID.'" name="orderID">';
echo '<input hidden value="'.$tilleggID.'" name="tilleggID">';
echo '<input hidden value="'.$status.'" name="status">';
echo '<input hidden value="'.$ukeID.'" name="ukeID">';
echo '<input hidden value="yes" name="viewtime">';
?>
</form>