日期:2014-05-20  浏览次数:20754 次

获得select索引值?
前台的一个select(HTML控件),我将它转为服务器控件,它的option选项我是用js动态添加,但是我在后台代码却获取不到它的选项索引值,一直都只为0,请问是怎么回事?问题出在哪里?虚心请教~~~

------解决方案--------------------
动态添加的东西,后台是不知道的,可以在提交到后台之前用js把选项放到一个hidden里面的,再从后台取的
------解决方案--------------------
C# code
<select id="select1" name="select1" onchanged="getSelectValue(this);">

<input id="hidGetValue" type="hidden" runat=server/>

function getSelectValue(obj)
{
   //for(var i=0;i<this.options.length;i++)
   //{
   //}
   var hid=document.getElementById("hidGetValue");
   hid.value=this.options(this.selectedIndex).value;
}