在Jsp中访问Javascript函数的索引属性

时间:2019-07-10 23:45:28

标签: javascript jsp properties access indexed

我有一个JSP页面,我正在尝试访问Javascript中值的checkCheckResult.rowChecked数组,如何访问它们?这些试验似乎都不起作用,我的目标是在property =“ availability” =“是”时检查property =“ examinerAvailabilityCheckbox”

        <logic:present name="QueueForm" property="checkExamAvail">
        <logic:iterate id="examCheckResult" name="QueueForm"
            property="checkExamAvail" indexId="index">

            <c:set var='value'
                value='${examCheckResult.examinerCode}$${examCheckResult.examinerName}$${examCheckResult.ddsUnitcode}
    $${examCheckResult.availability}$${examCheckResult.maximumClaimsAllowed}' />

            <html:hidden name="examCheckResult" property="rowChecked" value="${value}" indexed="true" />
            <html:hidden name="examCheckResult" property="availability" value="${examCheckResult.availability}" indexed="true" />
            <TD>
                <Table border="1">
                    <TR>
                        <td width="130"><bean:write name="examCheckResult"
                                property="examinerCode" /></td>
                        <td width="150"><bean:write name="examCheckResult"
                                property="examinerName" /></td>
                        <td width="100"><bean:write name="examCheckResult"
                                property="ddsUnitcode" /></td>

                        <td width="100"><html:text name="examCheckResult"
                                property="maximumClaimsAllowed" size="5" indexed="true"></html:text></td>
                        <td width="130"><html:checkbox name="examCheckResult"
                                property="examinerAvailabilityCheckbox" styleId='${index}' 
                                onchange="changeCheckBoxAnswer('${index}')"  indexed="true" /></td> 
                        <td width="100"><bean:write name="examCheckResult"
                                property="workLoad" /></td>
                    </TR>
                </Table>

            </TD>

        </logic:iterate>
    </logic:present>

这是JavaScript函数:

    function checkUnavailableExaminers() {

            //var examiners = document.forms[0].getElementById['rowCheked'];
            //var examiners = document.getElementsByName('examCheckResult').length;
            //[0].rowCheked')
            //var x = document.forms[0].getElementById("examCheckResult").elements[0].value;
            //alert(x)
            //var examiners = document.forms[0].examCheckResult.value;

            var examiners = document.getElementByName("examCheckResult");
            alert(examiners.length);

            //var ex = document.forms[0].elements['examCheckResult'];


            for (var i = 0; i < examiners.length; i++) {
            alert("hello1:"+examiners[0].rowCheked);
                var value = examiners[i].availability;
                //var array = value.split("$");
            //  var availability = array[3];
                var availability = value;
                //alert("availability:"+availability);
                if (availability == 'No') {
                    alert("array3:"+availability);
                    document.forms[0].elements['examCheckResult[' + i
                            + '].examinerAvailabilityCheckbox'].checked = true;
                }
            }
        }

0 个答案:

没有答案