It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Error on Page

Error on Page

Postby Santanu on Thu Oct 23, 2008 6:12 pm

when I run this page on the browser on the bottom left corner I am getting "Error on page" with warning yellow triangle sign. If I click on this triangle sign the information below shows in a pop up window.

Line: 726
Char: 4
Error: 'length' is null or not an object
Code: 0
URL: http://....../WardenConfig/deviceNoiceAnalysis.jsp

I did some experiment on this issue and I found when we remove this <body onLoad="setDefaultNoiseTime();"> form the JSP the error does not exist. So I beleive this javascript error is generating in the function "setDefaultNoiseTime()". But I could not figure out what is the problem in this function. The function is below:

function setDefaultNoiseTime()
{
// Find the current date and hour
// Set the start date and time to the current date and hour
// Set the end date and time to the current date and hour

var now = new Date();
var currentYear = "" + now.getYear();
var currentMonth = "" + (now.getMonth() + 1); // 1-12

// if( currentMonth.length == 1 )
// {
// currentMonth = "0" + currentMonth;
// }

var currentMonthName = getMonthName( currentMonth );

var currentDay = "" + now.getDate();
if( currentDay.length == 1 )
{
currentDay = "0" + currentDay;
}
var currentHour = "" + now.getHours(); // 0-23
if( currentHour.length == 1 )
{
currentHour = "0" + currentHour;
}

// Now select the appropriate index in each dropdown :
setSelection( document.formSettings.selectStartYear, currentYear );
setSelection( document.formSettings.selectStartMonth, currentMonthName );
setSelection( document.formSettings.selectStartDay, currentDay );
setSelection( document.formSettings.selectStartHour, currentHour );

setSelection( document.formSettings.selectEndYear, currentYear );
setSelection( document.formSettings.selectEndMonth, currentMonthName );
setSelection( document.formSettings.selectEndDay, currentDay );
setSelection( document.formSettings.selectEndHour, currentHour );
}

Please help me to resolve this issue. Thanks....
Santanu
 
Posts: 16
Joined: Sat Aug 09, 2008 5:20 pm

Postby rangana on Fri Oct 24, 2008 12:35 am

Download firebug. It will help you debug on the problem.

...and at our end, we can't be of any help without seeing the markups involved and the remaining function (setSelection(), getMonthName())
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby Santanu on Fri Oct 24, 2008 1:35 pm

here is the markup language:
Code: Select all
<form name="formSettings" method="post" action="./servlet/WardenConfigController" target="_blank">
<input type="hidden" name="wardenAction" value="">

    <table class="main" border="0" cellspacing="0" cellpadding="0">
      <jsp:include page="begin.jsp">
        <jsp:param name="title" value="<%=TITLE%>"/>
      </jsp:include>

      <!-- a row with the body of the page -->
      <tr>
        <td>
          <table height="100%" width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <!-- the navigation column : hard-coded width of 160 pixels -->

              <td class="nav-column">
                <br>
            <%=ConfigNavigator.getInstance().HtmlNavigation( "noise-analysis" )%>
              </td>
             
<%
            if( theDevices != null )
            {
%>
              <td class="main-column"> <!-- the main content column -->
                <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EFEFEF">

              <tr>
                <td align="center">&nbsp; </td>
              </tr>

              <tr>
               <td align="center">
                 <table width="88%" height="23" border="0" cellpadding="0" cellspacing="0">
                   <tr>
                     <td class="input-style-3">&nbsp;</td>
                     <td class="input-style-3">YYYY</td>
                     <td class="input-style-3">MM</td>
                     <td class="input-style-3">DD</td>
                     <td class="input-style-3">HH</td>
                     <td width="11%" class="input-style-3">MM</td>
                      <td width="8%" class="input-style-3">&nbsp;</td>
                   </tr>
                   <tr>
                     <td class="input-style-3"><div align="left">Start Date/Time : </div></td>
                    <td width="13%" class="input-style-3">
                      <div align="center">
                        <select name="selectStartYear" size="1" id="selectStartYear">
                           <option value="2007">2007</option>
                           <option value="2008">2008</option>
                           <option value="2009">2009</option>
                           <option value="2010">2010</option>
                           <option value="2011">2011</option>
                           <option value="2012">2012</option>
                           <option value="2013">2013</option>
                           <option value="2014">2014</option>
                           <option value="2015">2015</option>
                           <option value="2016">2016</option>
                           <option value="2017">2017</option>
                           <option value="2018">2018</option>
                           <option value="2019">2019</option>
                           <option value="2020">2020</option>
                          </select>
                        </div></td>
                    <td width="12%" class="input-style-3">
                            <div align="center">
                              <select name="selectStartMonth" size="1" id="selectStartMonth">
                           <option>Jan</option>
                           <option>Feb</option>
                           <option>Mar</option>
                           <option>Apr</option>
                           <option>May</option>
                           <option>Jun</option>
                           <option>Jul</option>
                           <option>Aug</option>
                           <option>Sep</option>
                           <option>Oct</option>
                           <option>Nov</option>
                           <option>Dec</option>
                              </select>
                      </div></td>
                    <td width="11%" class="input-style-3">
                            <div align="center">
                              <select name="selectStartDay" size="1" id="selectStartDay">
                           <option>01</option>
                           <option>02</option>
                           <option>03</option>
                           <option>04</option>
                           <option>05</option>
                           <option>06</option>
                           <option>07</option>
                           <option>08</option>
                           <option>09</option>
                           <option>10</option>
                           <option>11</option>
                           <option>12</option>
                           <option>13</option>
                           <option>14</option>
                           <option>15</option>
                           <option>16</option>
                           <option>17</option>
                           <option>18</option>
                           <option>19</option>
                           <option>20</option>
                           <option>21</option>
                           <option>22</option>
                           <option>23</option>
                           <option>24</option>
                           <option>25</option>
                           <option>26</option>
                           <option>27</option>
                           <option>28</option>
                           <option>29</option>
                           <option>30</option>
                           <option>31</option>
                              </select>
                      </div></td>
                    <td width="13%" class="input-style-3">
                            <div align="center">
                              <select name="selectStartHour" size="1" id="selectStartHour">
                           <option>00</option>
                           <option>01</option>
                           <option>02</option>
                           <option>03</option>
                           <option>04</option>
                           <option>05</option>
                           <option>06</option>
                           <option>07</option>
                           <option>08</option>
                           <option>09</option>
                           <option>10</option>
                           <option>11</option>
                           <option>12</option>
                           <option>13</option>
                           <option>14</option>
                           <option>15</option>
                           <option>16</option>
                           <option>17</option>
                           <option>18</option>
                           <option>19</option>
                           <option>20</option>
                           <option>21</option>
                           <option>22</option>
                           <option>23</option>
                              </select>
                     </div></td>
                    <td colspan="2" class="input-style-3">
                            <div align="left">
                                <select name="selectStartMinute" size="1" id="selectStartMinute">
                              <option>00</option>
                              <option>01</option>
                              <option>02</option>
                              <option>03</option>
                              <option>04</option>
                              <option>05</option>
                              <option>06</option>
                              <option>07</option>
                              <option>08</option>
                              <option>09</option>
                              <option>10</option>
                              <option>11</option>
                              <option>12</option>
                              <option>13</option>
                              <option>14</option>
                              <option>15</option>
                              <option>16</option>
                              <option>17</option>
                              <option>18</option>
                              <option>19</option>
                              <option>20</option>
                              <option>21</option>
                              <option>22</option>
                              <option>23</option>
                              <option>24</option>
                              <option>25</option>
                              <option>26</option>
                              <option>27</option>
                              <option>28</option>
                              <option>29</option>
                              <option>30</option>
                              <option>31</option>
                              <option>32</option>
                              <option>33</option>
                              <option>34</option>
                              <option>35</option>
                              <option>36</option>
                              <option>37</option>
                              <option>38</option>
                              <option>39</option>
                              <option>40</option>
                              <option>41</option>
                              <option>42</option>
                              <option>43</option>
                              <option>44</option>
                              <option>45</option>
                              <option>46</option>
                              <option>47</option>
                              <option>48</option>
                              <option>49</option>
                              <option>50</option>
                              <option>51</option>
                              <option>52</option>
                              <option>53</option>
                              <option>54</option>
                              <option>55</option>
                              <option>56</option>
                              <option>57</option>
                              <option>58</option>
                             <option>59</option>
                                </select>
                          </div></td>
                    </tr>
                   <tr>
                     <td width="32%" class="input-style-3"><div align="left">End Date/Time : </div></td>
                    <td width="13%" class="input-style-3">
                      <div align="center">
                        <select name="selectEndYear" size="1" id="selectEndYear">
                           <option value="2007">2007</option>
                           <option value="2008">2008</option>
                           <option value="2009">2009</option>
                           <option value="2010">2010</option>
                           <option value="2011">2011</option>
                           <option value="2012">2012</option>
                           <option value="2013">2013</option>
                           <option value="2014">2014</option>
                           <option value="2015">2015</option>
                           <option value="2016">2016</option>
                           <option value="2017">2017</option>
                           <option value="2018">2018</option>
                           <option value="2019">2019</option>
                           <option value="2020">2020</option>
                          </select>
                        </div></td>
                    <td width="12%" class="input-style-3">
                            <div align="center">
                              <select name="selectEndMonth" size="1" id="selectEndMonth">
                           <option>Jan</option>
                           <option>Feb</option>
                           <option>Mar</option>
                           <option>Apr</option>
                           <option>May</option>
                           <option>Jun</option>
                           <option>Jul</option>
                           <option>Aug</option>
                           <option>Sep</option>
                           <option>Oct</option>
                           <option>Nov</option>
                           <option>Dec</option>
                              </select>
                      </div></td>
                    <td width="11%" class="input-style-3">
                            <div align="center">
                              <select name="selectEndDay" size="1" id="selectEndDay">
                           <option>01</option>
                           <option>02</option>
                           <option>03</option>
                           <option>04</option>
                           <option>05</option>
                           <option>06</option>
                           <option>07</option>
                           <option>08</option>
                           <option>09</option>
                           <option>10</option>
                           <option>11</option>
                           <option>12</option>
                           <option>13</option>
                           <option>14</option>
                           <option>15</option>
                           <option>16</option>
                           <option>17</option>
                           <option>18</option>
                           <option>19</option>
                           <option>20</option>
                           <option>21</option>
                           <option>22</option>
                           <option>23</option>
                           <option>24</option>
                           <option>25</option>
                           <option>26</option>
                           <option>27</option>
                           <option>28</option>
                           <option>29</option>
                           <option>30</option>
                           <option>31</option>
                              </select>
                      </div></td>
                    <td width="13%" class="input-style-3">
                            <div align="center">
                              <select name="selectEndHour" size="1" id="selectEndHour">
                           <option>00</option>
                           <option>01</option>
                           <option>02</option>
                           <option>03</option>
                           <option>04</option>
                           <option>05</option>
                           <option>06</option>
                           <option>07</option>
                           <option>08</option>
                           <option>09</option>
                           <option>10</option>
                           <option>11</option>
                           <option>12</option>
                           <option>13</option>
                           <option>14</option>
                           <option>15</option>
                           <option>16</option>
                           <option>17</option>
                           <option>18</option>
                           <option>19</option>
                           <option>20</option>
                           <option>21</option>
                           <option>22</option>
                           <option>23</option>
                              </select>
                     </div></td>
                    <td colspan="2" class="input-style-3">
                            <div align="left">
                                <select name="selectEndMinute" size="1" id="selectEndMinute">
                              <option>00</option>
                              <option>01</option>
                              <option>02</option>
                              <option>03</option>
                              <option>04</option>
                              <option>05</option>
                              <option>06</option>
                              <option>07</option>
                              <option>08</option>
                              <option>09</option>
                              <option>10</option>
                              <option>11</option>
                              <option>12</option>
                              <option>13</option>
                              <option>14</option>
                              <option>15</option>
                              <option>16</option>
                              <option>17</option>
                              <option>18</option>
                              <option>19</option>
                              <option>20</option>
                              <option>21</option>
                              <option>22</option>
                              <option>23</option>
                              <option>24</option>
                              <option>25</option>
                              <option>26</option>
                              <option>27</option>
                              <option>28</option>
                              <option>29</option>
                              <option>30</option>
                              <option>31</option>
                              <option>32</option>
                              <option>33</option>
                              <option>34</option>
                              <option>35</option>
                              <option>36</option>
                              <option>37</option>
                              <option>38</option>
                              <option>39</option>
                              <option>40</option>
                              <option>41</option>
                              <option>42</option>
                              <option>43</option>
                              <option>44</option>
                              <option>45</option>
                              <option>46</option>
                              <option>47</option>
                              <option>48</option>
                              <option>49</option>
                              <option>50</option>
                              <option>51</option>
                              <option>52</option>
                              <option>53</option>
                              <option>54</option>
                              <option>55</option>
                              <option>56</option>
                              <option>57</option>
                              <option>58</option>
                             <option>59</option>
                                </select>
                          </div></td>
                  </tr>
                 </table>               
               </td>
              </tr>

              <tr>
                <td>
                    <hr>
                </td>
              </tr>

              <tr>
               <td align="center">
                 <div align="left"></div>
                 <div align="left"></div>
                 <table width="88%" height="23" border="0" cellpadding="0" cellspacing="0">
                   <tr>
                     <td width="47%" class="input-style-3"><div align="left">Device Name</div></td>
                    <td width="31%" class="input-style-3"><div align="left">Type</div></td>
                    <td width="22%" class="input-style-3"><div align="left">&nbsp;Noise</div></td>
                  </tr>
                 </table>               
               </td>
              </tr>

                  <tr>
                    <td align="center">
                      <div class="scrolldevicenoise">
                      &nbsp;<table id="tagTable" width="100%" border="0" cellspacing="0" cellpadding="1">
<%
                      int rowCount = 0;
                 String backColor = "";
                 if( theDevices != null )
                 {
                   for( int x = 0; x < theDevices.length; x++ )
                  {
                     String guid    = theDevices[x].getGUID();
                     String name    = theDevices[x].getName();
                     String type    = theDevices[x].getType();
                     String noiseGUIDFieldName = "noiseGUID" + x;
                     String noiseShowFieldName = "showNoise" + x;
                     
                     if( (rowCount % 2 == 0 ) )
                     {
                       backColor = "#FFFFFF";
                     }   
                     else
                     {
                       backColor = "#CCCCCC";
                     }
%>
                  <tr bgcolor="<%=backColor%>">
                    <td width="47%" class="input-style-4">
                      <div align="left"><%=name%></div></td>
                          <td width="32%" class="input-style-4">
                      <div align="left"><%=type%></div></td>
                          <td bgcolor="#CCCCCC" width="21%" class="input-style-4">
                            <div align="left">
                              <input name="<%=noiseGUIDFieldName%>" type="hidden" value="<%=guid%>">                           
                              <input type="checkbox" name="<%=noiseShowFieldName%>" value="true" onClick="updateCount(this);">
                          </div></td>
                       </tr>
<%
                          rowCount++;
                       }
                 }
%>
                      </table>           
                 </div>                    </td>
                  </tr> 
              <!-- ends row for data entry -->

              <tr>
                <td>
                    <hr>
                </td>
              </tr>

                  <!-- Row for buttons -->
                  <tr>
                    <td align="center">
                      <table width="50%" border="0" cellspacing="2" cellpadding="5">
                         <tr>
                         <td width="25%">
                            <div align="center">
                              <input name="btnNoise" type="button" id="btnNoise" onClick="handleShowNoise();" value="Show Noise" />
                            </div>
                        </td>
                         <!--td width="25%">
                            <div align="center">
                              <input name="btnClose" type="button" id="btnClose" onClick="handleClose();"     value="Close" />
                            </div>
                       </td-->
                        </tr>
                      </table>                     
                    </td>
                  </tr> 
              <!-- ends row for buttons -->

                </table>
              </td>  <!-- This ends "the main content column" -->

<%
      }  // end if( devices != null )
      else
      {
%>
              <td width="311" class="main-column"> <!-- the NULL DEVICE content column -->
                <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#EFEFEF">
                  <tr>
                    <td align="center">
                      <table width="90%" border="1" cellspacing="0" cellpadding="1">
                  <tr>
                    <td class="input-style-3"><div align="center">COULD NOT UPDATE NOISE DATA </div></td>
                   </tr>
                      </table>                     
                    </td>
                  </tr> 
                  <tr>
                    <td align="center">
                      <table width="90%" border="1" cellspacing="0" cellpadding="1">
                  <tr>
                         <td width="50%">
                              <div align="center">                            </div>
                          </td>
                   </tr>
                      </table>                     
                    </td>
                  </tr> 
                </table>
              </td>  <!-- This ends "the NULL DEVICE content column" -->
<%      
      }
%>           
         </tr>  <!-- this ends "a row with the body of the page" -->
        </table> <!-- This ends the "Table 1: And one table to hold them all" -->
      </td>
    </tr> 
  </table>
  </form>
Santanu
 
Posts: 16
Joined: Sat Aug 09, 2008 5:20 pm

Error on page

Postby Santanu on Fri Oct 24, 2008 1:37 pm

Here is the javascript functions:
Code: Select all
<script language="JavaScript" src="js/rftJSLib.js"></script>
<script language="JavaScript">
var totalCount = 0;
var maxCount   = 4;
function updateCount( field )
{
  if( field.checked )
  {
    totalCount++;
  }
  else
  {
    totalCount--;
  }
 
  //  alert( "totalCount was now " + totalCount );
}

function handleShowNoise()
{
  if( validate() )
  {
   // disable( document.formSettings.btnNoise );
    document.formSettings.wardenAction.value = "get.device.noise";
    document.formSettings.submit();
  }
}

function validate()
{
  if( totalCount > maxCount )
  {
    alert( "A maximum of " + maxCount + " devices may be selected." );
    return false;
  }
  else if( totalCount < 1 )
  {
    alert( "Please select a device." );
    return false;
  }
  else
  {
    return true;
  }
}

function handleClose()
{
  document.formSettings.wardenAction.value="launch.configuration";
  document.formSettings.submit();
}

function setDefaultNoiseTime()
{
    // Find the current date and hour
    // Set the start date and time to the current date and hour
    // Set the end date and time to the current date and hour
   
     var now = new Date();
     var currentYear  = "" + now.getYear();
     var currentMonth = "" + (now.getMonth() + 1);  // 1-12

//     if( currentMonth.length == 1 )
//     {
//       currentMonth = "0" + currentMonth;
//     }
     
     var currentMonthName = getMonthName( currentMonth );
     
     var currentDay   = "" + now.getDate();         
     if( currentDay.length == 1 )
     {
       currentDay = "0" + currentDay;
     }
     var currentHour  = "" + now.getHours();        // 0-23
     if( currentHour.length == 1 )
     {
       currentHour = "0" + currentHour;
     }
     
     // Now select the appropriate index in each dropdown :
     setSelection( document.formSettings.selectStartYear,  currentYear );
     setSelection( document.formSettings.selectStartMonth, currentMonthName );
     setSelection( document.formSettings.selectStartDay,   currentDay );
     setSelection( document.formSettings.selectStartHour,  currentHour );
 
     setSelection( document.formSettings.selectEndYear,  currentYear );
     setSelection( document.formSettings.selectEndMonth, currentMonthName );
     setSelection( document.formSettings.selectEndDay,   currentDay );
     setSelection( document.formSettings.selectEndHour,  currentHour );
  }
</script>
Santanu
 
Posts: 16
Joined: Sat Aug 09, 2008 5:20 pm

Postby rangana on Sat Oct 25, 2008 3:14 am

We need to see the parsed markup, not the raw one.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines


Who is online

Users browsing this forum: No registered users and 7 guests