【发布时间】:2009-02-26 19:05:49
【问题描述】:
我正在尝试访问由 SQL Server Reporting Services 使用 JavaScript 创建的页面中的下拉框。我通常只是 getElementById 但下拉元素的 id 和 name 属性是由服务器生成的,所以我不想用它来引用元素。即如果页面的设计在未来发生变化,它会将元素命名为 _ct105 或 _ct107
我在页面上指定的唯一内容是标签“营业期间”。我正在考虑使用 xpath 来引用该跨度,然后使用下一个选择元素的相对位置,但我不知道该怎么做。
理想情况下,我可以指定 Select 元素本身的 ID 或名称(或任何其他属性)。这可能吗?
我将在页面上使用 jQuery,所以如果有人能想出一个好的方法来找到它,那就太好了。
<tr IsParameterRow="true">
<td class="ParamLabelCell">
<span>Business Period</span>
</td>
<td class="ParamEntryCell" style="padding-right:0px;">
<div>
<select name="ctl140$ctl00$ctl03$ddValue" id="ctl140_ctl00_ctl03_ddValue"> <!-- This is the select box I want -->
<option value="0"><Select a Value></option>
<option value="1">Customer</option>
<option value="2">Previous Week</option>
<option value="3">Current Week</option>
<option value="4">Next Week</option>
</select>
</div>
</td>
【问题讨论】: