gpt4 book ai didi

javascript - 如果 DOM 中没有表单,如何获取选择/选项列表

转载 作者:行者123 更新时间:2023-11-28 10:34:08 25 4
gpt4 key购买 nike

得到以下 Html block ...

<div style="visibility:visible" id="stateProvinceDiv">
<div id="stateUSALabelDiv"><label for="stateUSAIdSelect">Find Your Bookstore</label></div>
&nbsp;<select size="1" id="stateUSAIdSelect" name="stateUSAId">
<option>Loading...</option>
</select>
</div>

选择的页面/内容是由 javascript 函数/调用生成的...我可以获取该页面,因此我得到了一个 HtmlPage 实例。

鉴于我不知道如何获取选择/选项DOM 中有一个“form”元素。指向代码块的指针处理这个问题将不胜感激。

实际的 Html 如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>College Textbooks: College Apparel, College Gifts & Used College Books: eFollett.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="description" content="From used college books to up-to-date college textbooks and great college gifts like your school?s latest college apparel and more, visit efollett.com."/>
<meta name="keywords" content="college textbooks, used college books, college apparel, college gifts"/>

<script type="text/javascript" src="/wcsstore/HostedStoreFrontAssetStore/javascript/prototype-1.5.0.js"></script>
<script type="text/javascript" src="/wcsstore/HostedStoreFrontAssetStore/javascript/Util.js"></script>

<script type="text/javascript" src="/wcsstore/HostedStoreFrontAssetStore/javascript/flPrototypeHelper.js"></script>
<link rel="stylesheet" href="/wcsstore/HostedStoreFrontAssetStore/css/style1.css" type="text/css" />
</head>
<body onload="accessibleSelect();" id="global">


<!-- BEGIN COREMETRICS SUPPORT -->
<script language="javascript1.2" src="/wcsstore/HostedStoreFrontAssetStore/javascript/eluminate.js" type="text/javascript"></script>
<script language="javascript1.2" src="/wcsstore/HostedStoreFrontAssetStore/javascript/cmdatatagutils_WC.js" type="text/javascript"></script>

<script language="javascript1.2" type="text/javascript">
//<![CDATA[
cmSetProduction();
var cm_ClientID="90227440";
cmCreatePageviewTag("efollett Home Page","10051_HOME",null,null,"10051");
//]]>
</script>
<!-- END COREMETRICS -->

<div id="wrap">
<!-- start header -->
<table width="900" border="0" cellpadding="0" cellspacing="0" id="header">
<tr>
<td>
<table width="900" border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="skip_to_content" align="left" valign="top">
<ul>
<li><a href="#content" title="Skip to Content">Skip to Content</a></li>
</ul>
</td>
<td align="right" valign="top" id="your_account">
<ul>
<li>&nbsp;<strong>Serving Colleges and Universities</strong> | Online and On Campus</li>
<li> | <a href="/webapp/wcs/stores/servlet/FLLogon?langId=-1&amp;catalogId=10001&amp;storeId=10051" title="Your Account">Your Account</a></li>
<li> | Shopping Cart<span class="cart_total">: 0</span> | </li>
<li>Subtotal:<span class="subtotal"> $0.00</span> </li>
</ul>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<img src="http://images.efollett.com/htmlroot/images/templates/storeLogos/411.gif" alt="efollett.com. Online. On Campus." width="272" height="168" border="0" />
<img src="http://images.efollett.com/htmlroot/images/templates/storeBanners/411.jpg" alt="" width="624" height="168" border="0" /></td>
</tr>

<tr>
<td id="top_nav">
<h2 class="invisible">Site Menu</h2>
<ul>
<li><a href="/Home/10001-10051-1?demoKey=d" title="Home">Home</a></li>
<li>
| <a href="/webapp/wcs/stores/servlet/SpecialOfferView?langId=-1&amp;catalogId=10001&amp;storeId=10051&demoKey=d" title="Special Offers">Special Offers</a>
</li>
<li> | <a href="/webapp/wcs/stores/servlet/HelpStoreInfoView?langId=-1&amp;catalogId=10001&amp;storeId=10051&demoKey=d" title="Contact Us">Contact Us</a></li>
<li> |<a href="/webapp/wcs/stores/servlet/BuybackInfoView?langId=-1&amp;catalogId=10001&amp;storeId=10051&demoKey=d">Cash For Books</a></li>
</ul></td>
<tr>
</table>

<table width="900" border="0" cellpadding="0" cellspacing="0">
<tr>
<!-- START CONTENT -->
<td align="left" valign="top"><!--intro table-->

<table border="0" cellspacing="5" cellpadding="0" width="899">
<tr>
<td align="left" valign="top" width="203"><img src="http://images.efollett.com/htmlroot/images/templates/endeca/global/global_merch.jpg" alt="" width="203" height="140" /></td>
<td align="left" valign="top"><h1 class="secondaryPageHeaderHomepage"><a name="content" id="thecontent"></a>

Welcome to the efollett.com network of online bookstores!</h1>
<p> efollett.com provides you with access to over 1,200 online bookstores across the United States and Canada so you can quickly locate your campus store. </p><p> Order your college textbooks, used college books and merchandise by shopping your bookstore's online website. Each bookstore selects the college apparel and other products from their store inventory and fulfills the order, so you are actually shopping at your local bookstore. We do it this way because your campus bookstore is the best source for textbooks, college gifts and merchandise specific to your campus. </p><p><strong>Please locate your college, university or school from our drop down menus below</strong></p></td>
</tr>
</table>
<div id="storefinder">

<table cellpadding="0" cellspacing="6">
<tr style="border: none;">
<td style="border: none;">
<div id="errorDiv" style="display:none;visibility:hidden;color:red;" class="text"> </div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<!-- <img src="http://images.efollett.com/htmlroot/images/templates/storeLogos/us_university." width="290" border="0" /> -->
<h2 class="us">U.S. College and Universities</h2>

<br />
<div style="visibility:visible" id="stateProvinceDiv">
<div id="stateUSALabelDiv"><label for="stateUSAIdSelect">Find Your Bookstore</label></div>
&nbsp;<select size="1" id="stateUSAIdSelect" name="stateUSAId">
<option>Loading...</option>
</select>
</div>
<br />


<div style="display:none;visibility:hidden" id="institutionUSADiv">
<div id="institutionUSALabelDiv"><label for="institutionUSAIdSelect">Select Your Institution</label></div>
&nbsp;<select size="1" id="institutionUSAIdSelect" name="institutionUSAId">
</select>
</div>
<br />

<div style="display:none;visibility:hidden" id="campusUSADiv">
<div id="campusUSALabelDiv"><label for="campusUSAIdSelect">Select Your Campus</label></div>

&nbsp;<select size="1" id="campusUSAIdSelect" name="campusUSAId">
</select>
</div>
<br />

<div style="display:none;visibility:hidden" id="programUSADiv">
<div id="programUSALabelDiv"><label for="programUSAIdSelect">Select Your Program</label></div>
&nbsp;<select size="1" id="programUSAIdSelect" name="programUSAId"></select>
</div>
&nbsp;<div id="buttonDivUS"></div>

<img src="http://images.efollett.com/htmlroot/images/templates//spacer.gif" width="1" height="3" hspace="0" vspace="0" border="0" alt="" />

</td>


<td align="left" valign="top">
<h2 class="canada">Canada Colleges and Universities </h2>
<br />
<div style="visibility:visible" id='stateProvince2Div'>
<div id='stateCALabelDiv'><label for="stateCAIdSelect">Find Your Bookstore</label></div>
&nbsp;<select size="1" id="stateCAIdSelect" name="stateCAId">

<option>Loading...</option>
</select>
</div>
<br />

<div style="display:none;visibility:hidden" id="institutionCADiv">
<div id="institutionCALabelDiv"><label for="institutionCAIdSelect">Select Your Institution</label></div>
&nbsp;<select size="1" id="institutionCAIdSelect" name="institutionCAId"></select>
</div>

<br />

<div style="display:none;visibility:hidden" id="campusCADiv">
<div id="campusCALabelDiv"><label for="campusCAIdSelect">Select Your Campus</label></div>
&nbsp;<select size="1" id="campusCAIdSelect" name="campusCAId"></select>
</div>
<br />

<div style="display:none;visibility:hidden" id="programCADiv">
<div id="programCALabelDiv"><label for="programCAIdSelect">Select Your Program</label></div>

&nbsp;<select size="1" id="programCAIdSelect" name="programCAId"></select>
</div>
&nbsp;<div id="buttonDivCA"></div>
<img src="http://images.efollett.com/htmlroot/images/templates//spacer.gif" width="1" height="3" hspace="0" vspace="0" border="0" alt="" />

</td>

<td align="left" valign="top">
<h2 class="us">U.S Schools K-12 </h2>
<br />
<div style="visibility:visible" id="stateProvince3Div">

<div id="stateUSK12LabelDiv"><label for="stateUSK12IdSelect">Find Your Bookstore</label></div>
&nbsp;<select size="1" id="stateUSK12IdSelect" name="stateUSK12Id">
<option>Loading...</option>
</select>
</div>
<br />
<div style="display:none;visibility:hidden" id="institutionUSK12Div">
<div id="institutionUSK12LabelDiv"><label for="institutionUSK12IdSelect">Select Your Institution</div>

&nbsp;<select size="1" id="institutionUSK12IdSelect" name="institutionUSK12Id"></select>
</div>
<br />

<div style="display:none;visibility:hidden" id="campusUSK12Div">
<div id="campusUSK12LabelDiv"><label for="campusUSK12IdSelect">Select Your Campus</label></div>
&nbsp;<select size="1" id="campusUSK12IdSelect" name="campusUSK12Id"></select>
</div>
<br />

<div style="display:none;visibility:hidden" id="programUSK12Div">

<div id="programUSK12LabelDiv"><label for="programUSK12IdSelect">Select Your Program</label></div>
&nbsp;<select size="1" id="programUSK12IdSelect" name="programUSK12Id"></select>
</div>
&nbsp;<div id="buttonDivK12"></div>
<img src="http://images.efollett.com/htmlroot/images/templates//spacer.gif" width="1" height="3" hspace="0" vspace="0" border="0" alt="" />

</td>
</tr>
</table>

<script type="text/javascript">
//<![CDATA[
String.prototype.startsWith = function(s) { return this.indexOf(s)==0; }

var uri = '/webapp/wcs/stores/servlet/StoreFinderAJAX';
var servletPath = '/webapp/wcs/stores/servlet/';
var pageType = 'FLGStoreCatalogDisplay';
var catalogId = '10001';
var categoryId = 'null';
var langId = '-1';
var demoKey = 'null';
var extraParams = 'null'; // only used for User Registration page
var multiSelect = false;
var forwardURLLocation = '';

// This map is used to determine the URI used for forwarding the user
var forwardPage = Object;
forwardPage['FLGStoreCatalogDisplay'] = 'StoreCatalogDisplay';
forwardPage['FLUserSelectSchool'] = 'UserAccountUpdateDemographicsForm';
forwardPage['FLGBuybackInfoPage'] = 'AboutBuybackView';
forwardPage['FLEdoptionsDisplayGlobal'] = 'EdoptionSearchView';
forwardPage['CGSelectStoreDisplay'] = 'CustomtsSelectedStore';
forwardPage['FLLocateStoreCourseMaterials'] = 'LocateCourseMaterialsView';
forwardPage['FLGGenMerchDisplay'] = 'CategoryDisplay';

function onPageLoad() {
AjaxQueue.setBatchSize(1);

getData(buildParms('STATESUS', 'US', 'stateUSAIdSelect'));
getData(buildParms('STATESCA','CA', 'stateCAIdSelect'));
getData(buildParms('STATESK12','K12', 'stateUSK12IdSelect'));
}

accessibleSelect=function(){
var selectedStateUSIndex;
var selectedInstUSIndex;
var selectedCampusUSIndex;
var selectedProgramUSIndex;

var selectedStateCAIndex;
var selectedInstCAIndex;
var selectedCampusCAIndex;
var selectedProgramCAIndex;

var selectedStateK12Index;
var selectedInstK12Index;
var selectedCampusK12Index;
var selectedProgramK12Index;

var stateUSAIdSelectBox = document.getElementById("stateUSAIdSelect");
stateUSAIdSelectBox.onchange=function(){
callUSStateAjax();
};
stateUSAIdSelectBox.onkeyup=function(e){
callUSStateAjax();
};
function callUSStateAjax() {
if(selectedStateUSIndex != stateUSAIdSelectBox.selectedIndex) {
doAJAXSelect("onStateUSASelect()");
selectedStateUSIndex = stateUSAIdSelectBox.selectedIndex;
selectedInstUSIndex = '';
selectedCampusUSIndex = '';
selectedProgramUSIndex = '';
}
}

var institutionUSAIdSelectBox = document.getElementById("institutionUSAIdSelect");
institutionUSAIdSelectBox.onchange=function(){
callInstUSAjax();
};
institutionUSAIdSelectBox.onkeyup=function(e){
callInstUSAjax();
};
function callInstUSAjax() {
if(selectedInstUSIndex != institutionUSAIdSelectBox.selectedIndex) {
doAJAXSelect("onInstituteUSASelect()");
selectedInstUSIndex = institutionUSAIdSelectBox.selectedIndex;
selectedCampusUSIndex = null;
selectedProgramUSIndex = null;
}
}

var campusUSAIdSelectBox = document.getElementById("campusUSAIdSelect");
campusUSAIdSelectBox.onchange=function(){
callCampusUSAjax();
};
campusUSAIdSelectBox.onkeyup=function(e){
callCampusUSAjax();
};
function callCampusUSAjax() {
if(selectedCampusUSIndex != campusUSAIdSelectBox.selectedIndex) {
doAJAXSelect("onCampusSelect_USA()");
selectedCampusUSIndex == campusUSAIdSelectBox.selectedIndex;
selectedProgramUSIndex = null;
}
}

var programUSAIdSelectBox = document.getElementById("programUSAIdSelect");
programUSAIdSelectBox.onchange=function(){
callProgramUSAjax();
};
programUSAIdSelectBox.onkeyup=function(e){
callProgramUSAjax();
};
function callProgramUSAjax() {
if(selectedProgramUSIndex != programUSAIdSelectBox.selectedIndex) {
doAJAXSelect("onProgramSelect_USA()");
selectedProgramUSIndex = programUSAIdSelectBox.selectedIndex;
}
}

var stateCAIdSelectBox = document.getElementById("stateCAIdSelect");
stateCAIdSelectBox.onchange=function(){
callStateCAAjax();
};
stateCAIdSelectBox.onkeyup=function(e){
callStateCAAjax();
};

function callStateCAAjax() {
if(selectedStateCAIndex != stateCAIdSelectBox.selectedIndex) {
doAJAXSelect("onStateCASelect()");
selectedStateCAIndex = stateCAIdSelectBox.selectedIndex;
selectedInstCAIndex = null;
selectedCampusCAIndex = null;
selectedProgramCAIndex =null;
}
}


var institutionCAIdSelectBox = document.getElementById("institutionCAIdSelect");
institutionCAIdSelectBox.onchange=function(){
callInstCAAjax();
};
institutionCAIdSelectBox.onkeyup=function(e){
callInstCAAjax();
};
function callInstCAAjax() {
if(selectedInstCAIndex != institutionCAIdSelectBox.selectedIndex) {
doAJAXSelect("onInstituteCASelect()");
selectedInstCAIndex = institutionCAIdSelectBox.selectedIndex;
selectedCampusCAIndex = null;
selectedProgramCAIndex = null;
}
}


var campusCAIdSelectBox = document.getElementById("campusCAIdSelect");
campusCAIdSelectBox.onchange=function(){
callCampusCAAjax();
};
campusCAIdSelectBox.onkeyup=function(e){
callCampusCAAjax();
};
function callCampusCAAjax() {
if(campusCAIdSelectBox != campusCAIdSelectBox.selectedIndex) {
doAJAXSelect("onCampusSelect_CA()");
selectedCampusCAIndex == campusCAIdSelectBox.selectedIndex;
selectedProgramCAIndex = null;
}
}



var programCAIdSelectBox = document.getElementById("programCAIdSelect");
programCAIdSelectBox.onchange=function(){
callProgramCAAjax();
};
programCAIdSelectBox.onkeyup=function(e){
callProgramCAAjax();
};
function callProgramCAAjax() {
if(selectedProgramCAIndex != programCAIdSelectBox.selectedIndex) {
doAJAXSelect("onProgramSelect_CA()");
selectedProgramCAIndex = programCAIdSelectBox.selectedIndex;
}
}




var stateUSK12IdSelectBox = document.getElementById("stateUSK12IdSelect");
stateUSK12IdSelectBox.onchange=function(){
callStateK12Ajax();
};
stateUSK12IdSelectBox.onkeyup=function(e){
callStateK12Ajax();
};
function callStateK12Ajax() {
if(selectedStateK12Index != stateUSK12IdSelectBox.selectedIndex) {
doAJAXSelect("onStateUSK12Select()");
selectedStateK12Index = stateUSK12IdSelectBox.selectedIndex;
selectedInstK12Index = null;
selectedCampusK12Index = null;
selectedProgramK12Index = null;
}
}


var institutionUSK12IdSelectBox = document.getElementById("institutionUSK12IdSelect");
institutionUSK12IdSelectBox.onchange=function(){
callInstK12Ajax();
};
institutionUSK12IdSelectBox.onkeyup=function(e){
callInstK12Ajax();
};
function callInstK12Ajax() {
if(selectedInstK12Index != institutionUSK12IdSelectBox.selectedIndex) {
doAJAXSelect("onInstituteUSK12Select()");
selectedInstK12Index = institutionUSK12IdSelectBox.selectedIndex;
selectedCampusK12Index = null;
selectedProgramK12Index = null;
}
}



var campusUSK12IdSelectBox = document.getElementById("campusUSK12IdSelect");
campusUSK12IdSelectBox.onchange=function(){
callCampusK12Ajax();
};
campusUSK12IdSelectBox.onkeyup=function(e){
callCampusK12Ajax();
};
function callCampusK12Ajax() {
if(selectedCampusK12Index != campusUSK12IdSelectBox.selectedIndex) {
doAJAXSelect("onCampusSelect_USK12()");
selectedCampusK12Index == campusUSK12IdSelectBox.selectedIndex;
selectedProgramK12Index = null;
}
}


var programUSK12IdSelectBox = document.getElementById("programUSK12IdSelect");
programUSK12IdSelectBox.onchange=function(){
callProgramK12Ajax();
};
programUSK12IdSelectBox.onkeyup=function(e){
callProgramK12Ajax();
};
function callProgramK12Ajax() {
if(selectedProgramK12Index != programUSK12IdSelectBox.selectedIndex) {
doAJAXSelect("onProgramSelect_USK12()");
selectedProgramK12Index = programUSK12IdSelectBox.selectedIndex;
}
}
}

// Start state
function onStateUSASelect() {
hideLayer("errorDiv");hideLayer("programUSADiv");hideLayer("campusUSADiv");showLayer("institutionUSADiv");addLoadingOption("institutionUSA");
hideLayer("programCADiv");hideLayer("campusCADiv");hideLayer("institutionCADiv");
hideLayer("programUSK12Div");hideLayer("campusUSK12Div");hideLayer("institutionUSK12Div");
hideLayer("buttonDivUS");hideLayer("buttonDivCA");hideLayer("buttonDivK12");
selectFirst("stateCAIdSelect");
selectFirst("stateUSK12IdSelect");
if($('stateUSAIdSelect').value == '') {clearAJAXTimer();hideLayer("institutionUSADiv"); return; }
getData(buildParms('INSTITUTESUS', 'US', 'stateProvinceId='+$('stateUSAIdSelect').value)) ;
}

function onStateCASelect() {
hideLayer("errorDiv");hideLayer("programCADiv");hideLayer("campusCADiv");showLayer("institutionCADiv");addLoadingOption("institutionCA");
hideLayer("programUSADiv");hideLayer("campusUSADiv");hideLayer("institutionUSADiv");
hideLayer("programUSK12Div");hideLayer("campusUSK12Div");hideLayer("institutionUSK12Div");
hideLayer("buttonDivUS");hideLayer("buttonDivCA");hideLayer("buttonDivK12");
selectFirst("stateUSAIdSelect");
selectFirst("stateUSK12IdSelect");
if($('stateCAIdSelect').value == '') {clearAJAXTimer();hideLayer("institutionCADiv"); return; }
getData(buildParms('INSTITUTESCA', 'CA', 'stateProvinceId='+$('stateCAIdSelect').value)) ;
}

function onStateUSK12Select() {
hideLayer("errorDiv");hideLayer("programUSK12Div");hideLayer("campusUSK12Div");showLayer("institutionUSK12Div");addLoadingOption("institutionUSK12");
hideLayer("programUSADiv");hideLayer("campusUSADiv");hideLayer("institutionUSADiv");
hideLayer("programCADiv");hideLayer("campusCADiv");hideLayer("institutionCADiv");
hideLayer("buttonDivUS");hideLayer("buttonDivCA");hideLayer("buttonDivK12");
selectFirst("stateUSAIdSelect");
selectFirst("stateCAIdSelect");
if($('stateUSK12IdSelect').value == '') {clearAJAXTimer();hideLayer("institutionUSK12Div"); return; }
getData(buildParms('INSTITUTESK12', 'K12', 'stateProvinceId='+$('stateUSK12IdSelect').value)) ;
}
//End State

//Start Institute
function onInstituteUSASelect() {
hideLayer("errorDiv"); hideLayer("programUSADiv");hideLayer('campusUSADiv');hideLayer('buttonDivUS');
hideLayer("programCADiv");hideLayer("campusCADiv");hideLayer("institutionCADiv");
hideLayer("programUSK12Div");hideLayer("campusUSK12Div");hideLayer("institutionUSK12Div");
selectFirst("stateCAIdSelect");
selectFirst("stateUSK12IdSelect");
if($('institutionUSAIdSelect').value == '') {clearAJAXTimer();hideLayer("campusUSADiv"); return; }
getData(buildParms('CAMPUSUS','US', 'institutionId='+$('institutionUSAIdSelect').value));
}

function onInstituteCASelect() {
hideLayer("errorDiv");
hideLayer("programUSADiv");hideLayer("campusUSADiv");hideLayer("institutionUSADiv");
hideLayer("programCADiv");hideLayer("campusCADiv");
hideLayer("programUSK12Div");hideLayer("campusUSK12Div");hideLayer("institutionUSK12Div");
selectFirst("stateUSAIdSelect");
selectFirst("stateUSK12IdSelect");

if($('institutionCAIdSelect').value == '') {clearAJAXTimer();hideLayer("campusCADiv"); return; }
getData(buildParms('CAMPUSCA','CA','institutionId='+$('institutionCAIdSelect').value));
}

function onInstituteUSK12Select() {
hideLayer("errorDiv");hideLayer("programUSADiv");hideLayer('campusK12Div');hideLayer('buttonDivK12');
hideLayer("programUSADiv");hideLayer("campusUSADiv");hideLayer("institutionUSADiv");
hideLayer("programCADiv");hideLayer("campusCADiv");hideLayer("institutionCADiv");
selectFirst("stateUSAIdSelect");
selectFirst("stateCAIdSelect");
if($('institutionUSK12IdSelect').value == '') {clearAJAXTimer();hideLayer("campusUSK12Div"); return; }
getData(buildParms('CAMPUSK12','K12','institutionId='+$('institutionUSK12IdSelect').value));
}

// End of Institutions

// Start Campus

function onCampusSelect_USA() {
if($('campusUSAIdSelect').value == ''){clearAJAXTimer();hideLayer("programUSADiv"); hideLayer("errorDiv"); hideLayer("buttonDivUS"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
getData(buildParms('PROGRAMSUS','US','campusId='+$('campusUSAIdSelect').value + "&institutionId=" + $('institutionUSAIdSelect').value));
}

function onCampusSelect_CA() {
if($('campusCAIdSelect').value == ''){clearAJAXTimer();hideLayer("programCADiv"); hideLayer("errorDiv"); hideLayer("buttonDivCA"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
getData(buildParms('PROGRAMSCA','CA', 'campusId='+$('campusCAIdSelect').value + "&institutionId=" + $('institutionCAIdSelect').value));
}

function onCampusSelect_USK12() {
if($('campusUSK12IdSelect').value == ''){clearAJAXTimer();hideLayer("programUSK12Div"); hideLayer("errorDiv"); hideLayer("buttonDivK12"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
getData(buildParms('PROGRAMSK12','K12', 'campusId='+$('campusUSK12IdSelect').value + "&institutionId=" + $('institutionUSK12IdSelect').value));
}

// End of Campus

// Program Select
function onProgramSelect_USA() {
if($('programUSAIdSelect').value == ''){clearAJAXTimer();hideLayer("buttonDivUS"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
doForward($("programUSAIdSelect").value, null, 'buttonDivUS');
}

function onProgramSelect_CA() {
if($('programCAIdSelect').value == ''){clearAJAXTimer(); hideLayer("buttonDivCA"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
doForward($("programCAIdSelect").value, null,'buttonDivCA');
}

function onProgramSelect_USK12() {
if($('programUSK12IdSelect').value == ''){clearAJAXTimer();hideLayer("buttonDivK12"); return; }
// REMOVE THIS LATER
clearAJAXTimer();
doForward($("programUSK12IdSelect").value, null, 'buttonDivK12');
}
// End of Program Select.
// Loading Drop downs starts
function loadSTATESUS(data, meta) {
hideLayer("buttonDivUS");
hideLayer("buttonDivCA");
hideLayer("buttonDivK12");
addOptions("stateUSA", data, meta, "stateUSAIdSelect");
}

function loadSTATESCA(data, meta) {
hideLayer("buttonDivUS");
hideLayer("buttonDivCA");
hideLayer("buttonDivK12");
addOptions("stateCA", data, meta, "stateCAIdSelect");
}

function loadSTATESK12(data, meta) {
hideLayer("buttonDivUS");
hideLayer("buttonDivCA");
hideLayer("buttonDivK12");
addOptions("stateUSK12", data, meta, "stateUSK12IdSelect");
}

function loadINSTITUTESUS(data, meta) {

最佳答案

您可以使用原型(prototype)和选择的 id 来获取选择。

$('stateUSAIdSelect');

或者带有 css 规则的选项

$$('#stateUSAIdSelect option');

您实际上想用它们做什么?

更新:

抱歉,我误解了我想的问题。您想弄清楚如何使用 htmlunit 测试这些元素?

要获取选择,您可以使用getHtmlElementById

page.getHtmlElementById("stateUSAIdSelect");

从那里您可以调用 getChildNodes 从选择中获取所有选项。

htmlunit 的 javadoc 概述了您也应该能够使用的一大堆其他方法 http://htmlunit.sourceforge.net/apidocs/index.html .

希望有帮助。

关于javascript - 如果 DOM 中没有表单,如何获取选择/选项列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2157361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com