Html 如何忽略选择选项

Html 如何忽略选择选项,html,html-select,Html,Html Select,我的页面上有几个选择,名称为sport和processed。当我在第一次选择Soccer和第二次选择true时,我向服务器发出了这个请求:http://localhost/?sport=1&processed=true 我的问题是: 1) 是否可以忽略两个选择中的所有选项。因此,当我在两个或一个选项中选择All时,选择值在请求中被忽略 例如: | Sport | Processed | request | |--------|-

我的页面上有几个选择,名称为
sport
processed
。当我在第一次选择
Soccer
和第二次选择
true
时,我向服务器发出了这个请求:
http://localhost/?sport=1&processed=true

我的问题是:

1) 是否可以忽略两个选择中的所有选项。因此,当我在两个或一个选项中选择
All
时,选择值在请求中被忽略

例如:

| Sport  | Processed | request                                  |
|--------|-----------|------------------------------------------|
| All    | All       | http://localhost/                        |
| Soccer | All       | http://localhost/?sport=1                |
| All    | yes       | http://localhost/?processed=true         |
| Soccer | yes       | http://localhost/?sport=1&processed=true |
2) 是否可以只使用HTML而不使用JavaScript


标题

全部的
足球
网球

全部的 对 不


我认为没有javascript是做不到的。javascript解决方案可能是在提交时从表单中删除或禁用select标记,前提是所选值为空字符串

<script type="text/javascript">
      $(function(){
         $(':submit').click(function(){
              $('select').each(function(){
                  if ( $(this).val() == '' )
                  {
                      $(this).remove(); // or $(this).attr('disabled','disabled');
                  }
              });
         });
    });
</script>

$(函数(){
$(':submit')。单击(函数(){
$('select')。每个(函数(){
if($(this.val()='')
{
$(this.remove();//或$(this.attr('disabled','disabled');
}
});
});
});

我认为没有javascript是做不到的。javascript解决方案可能是在提交时从表单中删除或禁用select标记,前提是所选值为空字符串

<script type="text/javascript">
      $(function(){
         $(':submit').click(function(){
              $('select').each(function(){
                  if ( $(this).val() == '' )
                  {
                      $(this).remove(); // or $(this).attr('disabled','disabled');
                  }
              });
         });
    });
</script>

$(函数(){
$(':submit')。单击(函数(){
$('select')。每个(函数(){
if($(this.val()='')
{
$(this.remove();//或$(this.attr('disabled','disabled');
}
});
});
});