首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎样用JS获取弹出层中dropdownlist的selectedvalue值,该如何解决

2012-04-21 
怎样用JS获取弹出层中dropdownlist的selectedvalue值div class Dialog idAddOrEditRoleDialog styl

怎样用JS获取弹出层中dropdownlist的selectedvalue值
<div class=" Dialog" id="AddOrEditRoleDialog" style="top: 80px; width: 480px; display: none;
  text-align: center; margin: aotu;">
  <div class=" DialogHeader" onmousedown="javascript:Drag(this,$get('AddOrEditRoleDialog'),event)">
  <div class="DialogHeaderLeft">
  <div class="DialogExpandImage">
  <img src="../Resourse/Theme/images/add.gif" /></div>
  </div>
  <div id="PerAddMenu" class="DialogHeaderCenter">
  添加产品分类</div>
  <div id="PerEditRole" class="DialogHeaderCenter" style="display: none;">
  编辑产品名称</div>
  </div>
  <div class=" DialogContent" style="padding-top: 15px; padding-bottom: 15px;">
  <asp:UpdatePanel ID="UpdatePanelNewPerAssetReg" runat="server" UpdateMode="Conditional"
  ChildrenAsTriggers="false">
  <ContentTemplate>
  <table style="width: 90%;" class="styleTable">
  <tr>
  <td class="FormItemText">
  品牌名称:
  </td>
  <td class="FromItemLeft">
  <asp:DropDownList ID="DDL_CompanyName" runat="server" Width="155px">
  </asp:DropDownList>
  </td>
  <td class="FormItemText">
   
  </td>
  </tr>
  <tr>
  <td class="FormItemText">
  分类名称:
  </td>
  <td class="FromItemLeft">
  <asp:TextBox ID="TB_ProType" runat="server"></asp:TextBox>
  </td>
  <td class="FormItemText">
   
  </td>
  </tr>
   
  <tr>
  <td colspan="2" align="center">
  <asp:Button ID="SavePerRoletRegButton" AccessKey="F" onmouseover="javascript:this.className='ButtonOver'"
  onmouseout="javascript:this.className='Button'" runat="server" CssClass="Button"
  Text=" 添加(F) " OnClientClick="javascript:return checkSubmit();" OnClick="SavePerRoletRegButton_Click"
  UseSubmitBehavior="True" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <input class=" Button" accesskey="C" onmouseover="javascript:this.className='ButtonOver'"
  onmouseout="javascript:this.className='Button'" type="button" value=" 取消(C) "


  onclick="javascript:cancelSave();" />
  </td>
  </tr>
  </table>
  </ContentTemplate>
  </asp:UpdatePanel>
  </div>
  <div class=" DialogFooter">
  </div>
  </div>


JS
 function editRole() {  
  if ($get("<%=TB_rolId.ClientID%>").value.trim() == "") {
  alert("你没有选择要编辑的选项,请选择!");
  return false;
  }
   
  $get('AddOrEditRoleDialog').style.display = 'block';
  $get('PerEditRole').style.display = 'block';
  $get('DialogMask').style.display = 'block';  
  var table = $get("<%=GV_RoleList.ClientID %>");
  if (table && table.rows.length > 0) {
  var row = table.rows[table.rowIndex];
  $get("<%=TB_ProType.ClientID %>").value = row.getAttribute("FTypeName");
   
  }
  $get("<%=TB_addOreditRole.ClientID %>").value = "edit";
  $get("<%=SavePerRoletRegButton.ClientID %>").value = " 编辑(F) ";
  }

[解决办法]
document.getElementById("<%=XXX.ClientID%>").options.selectedValue
[解决办法]

 $('select#sel option:selected').val();

或者

$('select#sel').find('option:selected').val();

热点排行