-1
onclick="javascript:selectAllCheckBox(this,document.thisJSP.chkUser);"

Here , the Latest version of firefox and chrome shows below error message :-

TypeError: document.thisJSP is undefined

Where .thisJSP is my Form Name ...

Thnx in advance.

Here is my Form

<form action="AjaxRightsMenu.jsp" name="thisJSP" method="POST">
  <FieldSet>
    <Legend vAlign="Top">
      <Font color="green">User Details </Font>
    </Legend>
    <div vAlign="Top" style="overflow: scroll; height: 280px; max-height: 280px">
      <input type="hidden" name="hdnScrollValue" value="<%=myController.scrollValue%>">
      <Table Align="left" border="1" cellpadding="0" cellspacing="1" vAlign="Top" Width="100%">
        <Thead>
          <tr>
            <th width="9%" class="unsortable">
              <B><input type="button" name="chkSelectAll" value="Check All" onclick="javascript:selectAllCheckBox(this,document.thisJSP.chkUser);"></B>
            </th>
            <th align="left" Width="10%" colspan="1">Group Name</th>
            <th align="left" Width="10%" colspan="1">Loc Name</th>
            <th align="left" Width="10%" colspan="1">APP Name</th>
            <th align="left" Width="10%" colspan="1">Menu Name</th>
            <th align="left" Width="10%" colspan="1">View Rights</th>
            <th align="left" Width="10%" colspan="1">Add Rights</th>
            <th align="left" Width="10%" colspan="1">Edit Rights</th>
            <th align="left" Width="10%" colspan="1">Del Rights</th>
            <th align="left" Width="10%" colspan="1">Auth Rights</th>
          </tr>
        </Thead>
Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
NJM
  • 3
  • 3
  • 1
    Please provide full code which allows us to reproduce your issue. – Hidden Hobbes May 05 '18 at 06:12
  • Are DOM elements supposed to be accessible by name directly from document? Shouldn't you use [document.getElementsByName](https://www.w3schools.com/jsref/met_doc_getelementsbyname.asp) to get to the elements? – Andre Pena May 05 '18 at 06:14
  • @HiddenHobbes Please find the javascript below and the input tag from which this onclick event gets call...!!! – NJM May 05 '18 at 06:19
  • place your code here, specially where you define your form class or object. maybe it's because new JavaScript class definition. – Hamid May 05 '18 at 06:22
  • 1
    FYI, you don't need to put `javascript:` at the beginning of `onclick` attributes. That's only needed when you put JS in a URL. – Barmar May 05 '18 at 06:22
  • @Barmar : Yes, sir you are absolutely correct and i have added .js file in my jsp page from which the selectAllCheckBox(arg1,agr2); gets call – NJM May 05 '18 at 06:25
  • `document.forms['thisJSP']` – chiliNUT May 05 '18 at 06:26
  • @chiliNUT thnx it works ...but now same error msg is showing for .chkUser – NJM May 05 '18 at 07:09

2 Answers2

0

AFAK, your code is so UGLY!

Here is some suggestions:

  1. separate your ui definition and it's logic by define a new function;
  2. Use document.getElementById() function to reach the DOM element, not by name;
  3. You should try jQuery.
  • Thanks fro your advice but if you can provide example that can rellate my code then it would appreciated as m not in more touch with jQuery. – NJM May 05 '18 at 06:37
0

document.forms['thisJSP'].elements['chkUser']

See https://stackoverflow.com/a/16732108/2079345 and https://developer.mozilla.org/en-US/docs/Web/API/Document/forms

chiliNUT
  • 18,989
  • 14
  • 66
  • 106