VBA - 在IE中检查复选框

时间:2017-02-08 23:36:03

标签: html excel vba internet-explorer checkbox

我正在尝试检查网站上的复选框。

复选框HTML:

<input name="ApplicationSearchGroupsSelect_0" title='Select "Basic Access - Computer Logon"' type="checkbox" value="1">

支票箱上方的HTML:

<form name="main" id="main" onkeypress="return imOnKeyPress(event)" action="?facesViewId=/app/page/screen/standard_search.jsp" method="post">

代码

Set objinputs = aExplorer.document.getElementsByTagName("form")
For Each ele In objinputs
    If ele.Name Like "ApplicationSearchGroupsSelect_0" And ele.Title Like "Select "Basic Access - Computer Logon"" Then
        ele.Focus
        ele.Click
        ele.Selected = True
        ele.Checked = True
        ele.FireEvent "onkeypress"
        End If
    Next

    Do While aExplorer.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

    aExplorer.document.getElementById("main").FireEvent ("onkeypress")
    Do While aExplorer.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

当我尝试运行此代码时没有任何反应(没有错误消息,代码完成运行且未检查任何内容)。除了触发javascript事件,尝试单击按钮,选中复选框,make selected = true,我不知道如何单击此复选框,并且在网上搜索的时间没有返回任何内容。我也尝试将值更改为0,1,2并且没有任何结果。

有关如何检查我尝试过之外的复选框的任何想法?谢谢!

1 个答案:

答案 0 :(得分:1)

尝试

async function createRestaurant(req, res, next) {
    const restaurant = {
        name: req.body.name,
        description: req.body.description
    }

    const audits = {
        description: req.body.description
    }


    try {
        let query = "INSERT INTO restaurant SET ?";
        let resRestaurant = await connection.query(query, restaurant);

        let res_id = resRestaurant.insertId;

        const contactNumbers = {
            contact_number: req.body.mobile,
            restaurant_id: res_id
        }

        let query1 = "INSERT INTO contact_numbers SET ?";
        let resContact = await connection.query(query1, contactNumbers);

        let query2 = "INSERT INTO audits SET ?";
        let resAudit = await connection.query(query2, audits);

        return res.send(200);


    } catch (e) {
        console.log('err in requests', e);
        return res.json({
            message: e
        });

    }
}

module.exports = {
    createRestaurant: createRestaurant
}

或者,

aExplorer.document.forms("main").getElementsByName ("name=""ApplicationSearchGroupsSelect_0""")(0)