How should I specify an item in a checkbox list, when using the dom?

I am currently automating use of the wordpress editor using VBA in access 2003, but would like to extend the automation to include the selection of category, taxonomy items etc.
That is with Checkbox lists.
An example with the same structure is here: http://devblog.xing.com/frontend/the-checkbox-list/

My list is based on a hierarchy of geographic entities: On the local database I may have data associated with the locality: Algeria for instance.
I want to be able to use (ie As SHDocVw.InternetExplorer) ie.document.what?

Read More

I am a bit lost as to an elegant approach. I haven’t tried it yet but I guess I can get the innerhtml for each selectit class, check to see if it contains my keyword an if so extract the input id with a bit of string manipulation, and then use ie.document.getelementbyid(“whatever”).Click Check or Toggle

But is there a better approach?

(Ultimately I will have to look at how to connect to the remote database and drag the tag_id from the tables there – but I thought this would be quicker especially in that the automation functionality in a larger sense already exists)

Any pointers appreciated!

<ul id="localitieschecklist" class="categorychecklist form-no-clear"
data-wp-lists="list:localities">
<li id="localities-8" class="popular-category">
<label class="selectit">
<input id="in-localities-8" type="checkbox" name="tax_input[localities][]" value="8"> </input>
Africa
</label>
<ul class="children"><li id="localities-96">
<label class="selectit"><input id="in-localities-96" type="checkbox" name="tax_input[localities][]" value="96"></input>
Algeria
</label>

Related posts

Leave a Reply

1 comment

  1. Thanks for your help @Tim Williams. I am not sure that worked on the elegance front but it has enabled me to move forward, I run into a bit of headache with the hierarchical nature of the list, and time as dictated a compromise of only supporting the first two levels of the hierarchy. It will do for now, but any further comments are certainly welcome!

    Localities

        If artClassLocalities <> "" And Not IsNull(artClassLocalities) Then
            artClasses = Split(artClassLocalities, ",")
            Set Element = .Document.getElementByID("localitieschecklist")
    
            For i = 0 To Element.childNodes.Length - 1 'the element collection represents the globe
    
    
               'popular category items (6) one for each landmass
                Set Landmass = Element.childNodes(i)
               'landmass has 2 nodes
               'child 1 is the selectitnode node 0 (item 1)
                If InStr(1, artClassLocalities, Right(Landmass.childNodes(0).innerText, Len(Landmass.childNodes(0).innerText) - 1)) Then
                    Call Landmass.childNodes(0).childNodes(0).setAttribute("checked", True)
                Else
                    Call Landmass.childNodes(0).childNodes(0).setAttribute("checked", False)
                End If
    
                For j = 0 To Landmass.childNodes(1).childNodes.Length - 1 'the children are the countries
                    Set Country = Landmass.childNodes(1).childNodes(j)    ' a given child is a country
    
                    If InStr(1, artClassLocalities, Right(Country.childNodes(0).innerText, Len(Country.childNodes(0).innerText) - 1)) Then
                        Call Country.childNodes(0).childNodes(0).setAttribute("checked", True)
                    Else
                        Call Country.childNodes(0).childNodes(0).setAttribute("checked", False)
                    End If
                   'Support for Subregions not yet functional
                   'For k = 0 To Country.childNodes(1).childNodes.Length - 1
                    'Set PAndADiv = Country.childNodes(j)
    
                Next
            Next
        End If