使用VBA,我需要从下拉框中选择6中的一个选项,该框连接到Javascript,根据所选的选项更改下面的表格。
这是页面上的html代码:
<script type="text/javascript">
P.when('A','keyword-layout-model').register('keyword-layout-model-instance',
function(A, KeywordTargetingModel){
var model = new KeywordTargetingModel();
model.updateFromAdType('AAP_CPM');
A.on("a:dropdown:selected:lineItem.type", function (data) {
model.updateFromAdType(data.value);
});
return model;
})
</script>
<script type="text/javascript">
// Create an instance of the ad-type-model. If this is moved, then the documentation
// in AdTypeModel.js in the D16GRodeoBackbone package needs to be updated.
P.when('ad-type-model').register('ad-type-model-instance', function(AdTypeModel){
return new AdTypeModel({adType: 'AAP_CPM'}, {adTypeDropdownId: 'lineItem.type'});
});
</script>
<span id="lineItem.type_d16g-validation" class="d16g-validation d16g-component d16g-dropdown" for="lineItem.type">{"required":false}</span>
<span class="a-dropdown-container"><select name="lineItem.type" autocomplete="off" id="lineItem.type" tabIndex="-1" class="a-native-dropdown">
<option class="a-prompt" value="">Standard display</option>
<option value="AAP_MOBILE_APP">AAP - Mobile app</option>
<option value="AMAN_APP">AMAN - Mobile app</option>
<option value="AAP_MOBILE_WEB">AAP mobile display</option>
<option value="CLASS_I_MOBILE_APP">Class I - Mobile app</option>
<option value="CLASS_I_MOBILE_WEB">Class I - Mobile web</option><option value="CLASS_I_WEB">Class I display</option>
<option value="AAP_CPM" selected>Standard display</option>
<option value="AAP_VIDEO_CPM">Video</option>
</select>
<span tabIndex="-1" id="lineItem.type_controller" data-a-class="a-width-extra-large d16g-dropdownController" class="a-button a-button-dropdown a-width-extra-large d16g-dropdownController"><span class="a-button-inner"><span class="a-button-text a-declarative" data-action="a-dropdown-button" role="button" tabIndex="0" aria-hidden="true"><span class="a-dropdown-prompt">Standard display</span></span><i class="a-icon a-icon-dropdown"></i></span></span></span>
<div id="lineItem.type_error" class="a-box a-alert-inline a-alert-inline-error d16g-hidden d16g-errorMessage" aria-live="assertive" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"></div></div></div><div id="lineItem.type_serverError" class="a-box a-alert-inline a-alert-inline-error d16g-hidden d16g-serverErrorMessage" aria-live="assertive" role="alert"><div class="a-box-inner a-alert-container"><i class="a-icon a-icon-alert"></i><div class="a-alert-content"></div></div></div>
<script type="text/javascript">
P.when('D16G', 'jquery-1.9.0', 'A').register('refresh-form-ad-type', function(D16G, $, A) {
var options = {
saveButtonId : "bookAsLineItem",
classIForecastOverride : true,
canBookClassISov : true,
retailMerchandising : false,
budgetEntryRequired : true,
hideDSMLineEntry : false,
campaignType : "BILLABLE",
canBypassKsoForecast : false,
enableKsoOptimization : false,
enableKsoBuyingStrategy : false,
hasPermissionForViewability : false,
internalEntity : true,
internalUser : true
};
A.on("a:dropdown:selected:lineItem.type", function (data) {
D16G.Util.setAdType(data.value, options);
});
// trigger the initial event at page load
var id = '#' + D16G.Util.escapeId("lineItem.type");
A.trigger("a:dropdown:selected:lineItem.type", {value : $(id).val() });
// Return a function that can be used to trigger a refresh of the page's fields
return function(){
A.trigger("a:dropdown:selected:lineItem.type", {value : $(id).val() })
};
});
</script>
</div>
我尝试过使用以下VBA代码,但没有任何帮助。这个选项都没有被选中,下面的表格也没有改变。我认为有一个javascript被触发但我无法弄清楚如何。
Set campaignType = IE.document.getElementById("lineItem.type")
For i = 0 To campaignType.Options.Length
If campaignType.Options(i).Text = "Class I display" Then
campaignType.selectedIndex = i
Exit For
End If
Next i