1

私は現在、Access 2003 で VBA を使用してワードプレス エディターの使用を自動化していますが、自動化を拡張して、カテゴリ、分類項目などの選択を含めたいと考えています。それはチェックボックス リストです。同じ構造の例は次のとおりです: http://devblog.xing.com/frontend/the-checkbox-list/

私のリストは、地理的実体の階層に基づいています: ローカルデータベースには、地域に関連するデータがあるかもしれません: 例えばアルジェリア. 使用できるようにしたい (つまり、SHDocVw.InternetExplorer として) ie.document.what?

エレガントなアプローチについては少し迷っています。まだ試していませんが、各selectitクラスのinnerhtmlを取得できると思います。キーワードが含まれているかどうかを確認し、含まれている場合は、少し文字列操作して入力IDを抽出し、ie.document.getelementbyidを使用します("whatever")。[チェック] または [トグル] をクリックします。

しかし、より良いアプローチはありますか?

(最終的には、リモート データベースに接続してそこのテーブルから tag_id をドラッグする方法を検討する必要がありますが、より大きな意味での自動化機能が既に存在する場合は特に、これの方が速いと思いました)

任意のポインタをいただければ幸いです!

<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>
4

1 に答える 1

0

@Tim Williams さん、ご協力ありがとうございます。エレガンスの面でうまくいったかどうかはわかりませんが、前に進むことができました。リストの階層的な性質に少し頭が痛くなり、階層の最初の2つのレベルのみをサポートするという妥協が必要になりました。 . 今のところはこれで十分ですが、追加のコメントは大歓迎です!

地方

    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
于 2013-06-14T15:47:12.050 に答える