简体   繁体   中英

VBA Change ARIA-Controls Value

Good Morning,

I am trying to use VBA to fill an online form that uses "Aria". The program is very simple, and works for any form that doesn't use Aria, however I'm having a hard time adjusting it to this site. The HTML is as follows:

<div class="selectwrapper"> <label class="has-float-label shadow" for "event-0-line-0-name"> <div class="react-autosuggest__container" role="combobox" aria-expand ="false" aria-haspopup="listbox" aria-owns="react-autowhatever-event-0-line-0-name"> <input class="react-autosuggest__input" aria-controls="react-autowhatever-event-0-line-0-name" aria-autocomplete="list" type="text" placehold="" autocomplete="off" value = "" /> <div class="react-autosuggest__suggestions-container" id="react-autowhatever-event-0-line-0-name" role="listbox" value="VALUE FROM PROGRAM">

Currently I'm using .getElementByID , and .setAttribute("value", "random text") . In the HTML this does change the value of the ID, however on the form it is still blank. I think I have to change the value under aria-controls, but I'm not sure how to do this in VBA. (When I change the Value under Aria-Controls manually, it updates on the form.

I'm hoping this is an easy fix, I'm guessing I just have to change the .getElementByID to something else, but I'm not sure what that is. Any help is will be greatly appreciated. Thank you!

Currently I'm using .getElementByID , and .setAttribute("value", "random text") . In the HTML this does change the value of the ID

I don't follow what you're saying here. Setting the " value " attribute will not change the ID.

I think I have to change the value under aria-controls, but I'm not sure how to do this in VBA.

ARIA attributes are just like any other attribute and can be changed with setAttribute . For example to change the aria-expanded attribute, do this:

setAttribute('aria-expanded', 'true');

However, changing the ARIA attributes won't affect your form. ARIA attributes are hints to screen readers and other assistive technology and their values don't affect the visual display.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM