ComboBox怎么用?

JavaScript012

ComboBox怎么用?,第1张

沙发!!!

最简单的做法就是 打开VB

拖一个Combobox控件 选中它

在属性窗口找到LIST选项 点击 在里面 输入站点一 然后按ctrl+enter换行 继续输入站点二

OK 搞定~!

给分吧!

Html代码  

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  

<html>  

<head>  

<style>  

  

</style>  

<title>JS获取复选框被选中的值</title>  

</head>  

<body>  

<input type="checkbox" name="test" value="0" />0&nbsp&nbsp  

<input type="checkbox" name="test" value="1" />1&nbsp&nbsp  

<input type="checkbox" name="test" value="2" />2&nbsp&nbsp  

<input type="checkbox" name="test" value="3" />3&nbsp&nbsp  

<input type="checkbox" name="test" value="4" />4&nbsp&nbsp  

<input type="checkbox" name="test" value="5" />5&nbsp&nbsp  

<input type="checkbox" name="test" value="6" />6&nbsp&nbsp  

<input type="checkbox" name="test" value="7" />7&nbsp&nbsp  

<input type="button" onclick="chk()" value="提  交" />  

</body>  

</html>  

 

Js代码  

<script src="jquery.js"></script><!--这是载入jquery.js文件,如果不使用jquery可以去掉-->  

<script>  

function chk(){  

  var obj=document.getElementsByName('test')  //选择所有name="'test'"的对象,返回数组  

  //取到对象数组后,我们来循环检测它是不是被选中  

  var s=''  

  for(var i=0 i<obj.length i++){  

    if(obj[i].checked) s+=obj[i].value+','  //如果选中,将value添加到变量s中  

  }  

  //那么现在来检测s的值就知道选中的复选框的值了  

  alert(s==''?'你还没有选择任何内容!':s)  

}  

  

function jqchk(){  //jquery获取复选框值  

  var chk_value =[]  

  $('input[name="test"]:checked').each(function(){  

   chk_value.push($(this).val())  

  })  

  alert(chk_value.length==0 ?'你还没有选择任何内容!':chk_value)  

}  

</script>

先用jquery的append插入一段html  input,用js实现渲染input得到combobox ,

比如在一个div中加入combobox

$("div").append("<input id='combobox'></input")

$("#combobox").combobox({

    url:'getComboData',

    valueField:'value',

    textField:'text'

})