<form action="" method="post">
                <tr>
                  <td class="kuang_title"><input class="input" type="text" name="host" value="" size="7" />&nbsp;.&nbsp;XXX.COM</td>
                  <td class="kuang_title"><select id="type" name="type" class="select">
                      <option class="style_type_a" value="A" selected="selected">A</option>
                      <!-- <option class="style_type_b" value="B">B</option> -->
                    </select></td>
                  <td class="kuang_title"><input type="hidden" name="action" value="添加" />
                    <input type="submit" name="Submit" value="提交">
                    </td>
                </tr>
</form>以上代码是一个PHP语言中提交表单的代码,select 下面原来有“A”、“B”两个选项供选择,并提交执行相应的动作,后来,B选项被用<!--  -->
即: <!-- <option class="style_type_b" value="B">B</option> -->
注释而无法执行B命令,请问在“B”选项被注释的情况下,如何通过命令参数传递的或者其它可行的方式,直接执行原来B
选项的功能,就象B选项被隐藏前一样?

解决方案 »

  1.   

    在PHP程序中根据参数处理下拉选项数组。
      

  2.   

    1.值丢到隐藏域
    <input type="hidden" value="<!-- <option class='style_type_b' value='B'>B</option>" name="test" id="test" />
    2.document.getElementById('test').value取出
    3.用正则取出$string = "<!-- <option class='style_type_b' value='B'>B</option> -->";
    $pattern = "/<option(\s*\w+\s*=\s*\'(.*?)\').*?<\/option>/i";
    preg_match($pattern, $string, $matches);
    print_r($matches[0]);
      

  3.   

    把select节点之间的option全部取出来丢到隐藏域里面,再用js正则过滤到外面的注释,再丢回去就行,不用到服务器
      

  4.   

    <!-- <option class="style_type_b" value="B">B</option> -->
    是 HTML 注释,与 php 无关