dongre6404 2013-08-17 22:36
浏览 20

从下拉列表中选择时自动更改页面

I have limited JavaScript knowledge and am trying to change a form so it autochanges when the drop down is selected without having to click a go button.

How would I amend the following code? There are 3 separate drop downs in there. I've tried inserting onselect in there but it didnt seem to work?

<select name="season">
<option value="0"><?= $txt_all ?></option>
<?php
while($data = mysql_fetch_array($get_seasons))
{
    if($data['SeasonID'] == $defaultseasonid)
        echo "<option value=\"$data[SeasonID]\" SELECTED>$data[SeasonName]</option>
";
    else
        echo "<option value=\"$data[SeasonID]\">$data[SeasonName]</option>
";
}
mysql_free_result($get_seasons);
?>
</select>
<select name="matchtype">
<option value="0"><?= $txt_all ?></option>
<?php
while($data = mysql_fetch_array($get_types))
{
    if($data['MatchTypeID'] == $defaultmatchtypeid)
        echo "<option value=\"$data[MatchTypeID]\" SELECTED>$data[MatchTypeName]</option>
";
    else
        echo "<option value=\"$data[MatchTypeID]\">$data[MatchTypeName]</option>
";
}
mysql_free_result($get_types);
?>
</select> <input type="submit" name="submit" value="Go"><td bgcolor="<?php echo $inside_c ?>" align="center">
&nbsp;Other Stats <br><select name="changeto">

<option value="1"><?= $txt_match_statistics ?></option>
<option value="2"><?= $txt_recordbook ?></option>
<option value="5"><?= $txt_opponent_list ?></option>
<option value="6"><?= $txt_this_day ?></option>

</select> <input type="submit" name="changepage" value="Go">
  • 写回答

1条回答 默认 最新

  • douhua1760 2013-08-17 23:01
    关注

    With jQuery you can listen your drop down list when it changes.

    $('select').change(function(){
        // Do stuff
    });
    

    If you want to submit your form immediately after changing drop down value you can do this:

    $('select').change(function(){
        $('form').submit();
    });
    

    In right context you can see example from here(and mess around with it!): http://jsfiddle.net/EB635/

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动