JavaScript - Length Is Null Or Not An Object Error In Ie8
Hi,
I have added an validation script for Pizza menu. Validation working fine in all browsers except IE. When I working in IE8 it throws an error "length is null or not an object error in IE8". Please help me. See Java script code below: <script> function UnCheckRadios(radioButtonGroupName) { var formName = "frmOrder"; var form = document.forms[formName]; alert(form); var noOfRadioButtons=form[radioButtonGroupName].length; for(var x=0;x<noOfRadioButtons;x++) { chk=form[radioButtonGroupName] .checked=false; } } </script> PHP code: <input type="radio" id="<?=$subitem['subgroup_id'];?>_comboleft" name="<?=$subitem['subgroup_id'];?>_comboleft" value="<?=$subitem['id'];?>:Left Side" onclick="UnCheckRadios('<?=$subitem["subgroup_id"];?>_combowhole');"> Similar TutorialsHi, I started getting a wierd problem with my jscript program. Here im using jscript for client-side validation and upon email field submission,im getting undefined value with an error saying "length is null or not an object". All the values of fields prior to that are being obtained properly. Please help me out of this crisis Hi I am having trouble with a script. I cannot figure out why I get the message: error: null is null or not an object (In IE8) The site is: www.rayburns.com I have check the javascript for the navigation bar and for the rotating images and cannot see what is missing. Not sure what is not being called. Can someone please help with this. Thank you in advance! Hi, I am getting an error on this code - sometimes! - and I'm not sure what it is. If I run this as is there is no error. If I add it into another page with other stuff it's ok for a while and then I get an error. So, I added my new page block my block to this code and waited for the error to appear so I could determine a conflict - but it was fine. And then a few clicks later the error. This is the error in IE. In Firefox it seems to be fine lol. Line 159 Char 3 'window.document.sendform.message_text' is null or not an object Can someone make any suggestions? Code: <script language="JavaScript" type="text/javascript"> maxlen = 160; countLen(); function countLen() { message_text = window.document.sendform.message_text.value; realLength = message_text.length; if (realLength>maxlen) { realLength = maxlen; window.document.sendform.message_text.value = message_text.substring(0,maxlen); } message_text = window.document.sendform.message_text.value; // del enter var m = message_text.match(/[\r\n]/); if (m !== null) { window.document.sendform.message_text.value = message_text.replace(/[\n\r]/g, '') } window.document.sendform.messlen.value=maxlen-realLength; } </script> <cfset thismessage = "Hi, is this a start"> <cfform action="step2.cfm" method="post" id="sendform" name="sendform"> <cfoutput><textarea id="styled" name="message_text" onkeypress=countLen() onkeydown=countLen() onkeyup=countLen() onchange=countLen() onmouseover=countLen() rows="4">#thismessage#</textarea></cfoutput> <table width="331" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="5"></td> <td width="26"><cfoutput> <input name="messlen" type="text" value="160" class="counterField" onFocus="this.form.message_text.focus();" /></cfoutput></td> <td width="300">characters remaining</td> </tr> </table> </cfform> Thanks! Much appreciated! Kind regards, jo Hi I am using a custom form elements script in the link below: www_bristolstreet_co_uk/page/find_a_dealer.htm and an error for null object is appearing from this line: active = option[0].childNodes[0].nodeValue; Can anyone please help? I am a novice at Javascript but got this script working perfectly on my local machine - once I loaded it the live site it didn't work... any advice would be greatly appreciated. I have a bug that is only seeming to effect IE 8:. It seems to have a problem with this line: theSelectBox.selectedIndex = -1; This is where my full page is: http://www.mauirealestate.net/advancedsearch-rets.php Also has a weird display issue in IE8, but not in "compatibility view", which the bug may fix. Works and looks beautiful is Safari and Firefox. Any suggestions are helpful. Hello I am using a timer which goes down from 2 minutes to zero when 'jsp' is called. Timer is written in javascript. I am getting an error that document.form1.timerMin.value=<%=min%> is null or not an object. Here is the code (t.jsp): <% /* Default timer */ int min = 2; int sec = 5; /* Check for timer params */ try { String timerMin = request.getParameter("timerMin"); if (timerMin==null)timerMin=""; if (timerMin != null) { min = Integer.parseInt(timerMin); } String timerSec = request.getParameter("timerSec"); if (timerSec==null)timerSec=""; if (timerSec != null) { sec = Integer.parseInt(timerSec); } } catch(Exception m) { System.out.println("generated exception..............:"+m); } %> <script language="JavaScript" type="text/javascript"> <!-- /* Initialise timer */ var min = <%=min%>; // set the minutes var sec = <%=sec%>; // set the seconds function countDown() { sec--; if (sec == -1) { sec = 59; min--; } /* Write timer state to hidden form fields */ document.form1.timerMin.value=<%=min%> document.form1.timerSec.value=<%=sec%>; time = (min<=9 ? "0" + min : min) + " min and " + (sec<=9 ? "0" + sec : sec) + " sec "; document.getElementById('theTime').innerHTML = time; SD=window.setTimeout("countDown()", 1000); if (min == 0 && sec == 0) { window.clearTimeout(SD); } } window.onload = countDown(); --> </script> <style type="text/css"> <!-- .timeClass { font-family:arial,verdana,helvetica,sans-serif; font-weight:normal; font-size:10pt; } --> </style> <table width="100%"> <tr><td width="100%" align="right"> <span id="theTime" class="timeClass"></span> </td></tr> <form method="post" name="form1" id="form1" action="t.jsp" <td width="50%" valign="middle"> <input type="hidden" name="timerMin" value="<%=min%>"> <input type="hidden" name="timerSec" value="<%=sec%>"> <div align="center"><a href="javascript:form1.submit()" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','/lms/images/submit_0.gif',1)"><img name="Image3" border="0" src="/lms/images/submit_0.gif" width="70" height="30"></a></div> </td> </form> Looking forward for an early reply. Thanks Hi, first post here. I was working on code for opening a link in a new window when clicked. I read somewhere that it's a good idea to remove all of the javascript elements from the HTML. So I pieced it together and it works. But I get the following error in IE8: Code: Message: 'document.getElementById(...)' is null or not an object Here's the relevant HTML: Code: <a href="http://www.samplesite.com" id="sampleid">Sample Text</a> And here's the relevant javascript that I put in a seperate .js file: Code: function samplefct() { window.open(this.href);return false; } window.onload = function() {document.getElementById("sampleid").onclick = samplefct; } The code does work as planned. But I'd still like to get rid of the error. Can anybody think of a different way of stating the javascript that would perform the same thing and lose the error? Any help would be greatly appreciated. Thanks! IB Hey Guys, I wondered if anyone would be kind enough to look at an issue I am having running a Javascript on IE. The script works fine in FF and Chrome but chucks up an error in all versions of IE so the Menubar does not display child pages. Here's the Error: User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) Timestamp: Tue, 16 Aug 2011 14:45:53 UTC Message: 'lastChild' is null or not an object Line: 31 Char: 3 Code: 0 The full script is he http://www.makingtrails.com/wp-conte...ks3/js/menu.js Any help much appreciated as the author of this script is not providing any support. Thanks Jon Hi , I have a an application which works fine on XP IE6, but the same application throws error " Java Script Error Style is null or not an object" on XP IE8 and Windows 7 . Please help me to resolve this issue. Please Tahnks in advance For some reason i'm getting the error of "length is null". Which is from this . Code: function display_form(id) { //Create some variables var html = ""; var container = "form_container"; var menu = load_menu(id, false); //Get id for ( var i = 0; i < menu.length; i++ ) { alert(i); } http = getHTTPObject(); http.onreadystatechange = function() { if ( http.readyState == 4 && http.status == 200 ) { document.getElementById(container).innerHTML = http.responseText; } else { document.getElemenyById(container).innerHTML = "Loading..."; } } http.open( "GET", "includes/forms.php?form=" + id ); http.send(); //Watch input fields //login_listener(); }/* Here is the function: Code: function load_menu(menu, return_d) { //Availible menus var data = []; data [ 'login' ] = [ 'Login', 'Register', 'Recovery' ]; data [ 'settings' ] = [ 'Profile', 'Account', 'something' ]; if (return_d == false) { return data[ menu ]; } else { //Menu container ID's var cons = Array('menuitem1','menuitem2','menuitem3'); for ( var i = 0; i < cons.length; i++ ) { document.getElementById(cons[i]).innerHTML += data[ menu ] [ i ]; } } } Extra info: id = login menu = login Hi i have done some reading on the net today because i am getting an error on ie. I did find the javascript twice in my code, once in the header and once here, so i removed it from the header. I also changed to src to the full url. But i am still getting this and i dont know why. the file is located in the root directory. Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; msn OptimizedIE8;ENUS) Timestamp: Sat, 30 Jul 2011 16:03:05 UTC Message: 'null' is null or not an object Line: 8 Char: 3894 Code: 0 URI: http://www.mysite.com/swfobject.js Code: <script type='text/javascript' src='$CONST_LINK_ROOT/swfobject.js'></script> <script type='text/javascript'> var s1 = new SWFObject('player.swf','player','400','300','9'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv'); s1.write('preview'); </script> <embed src='$CONST_LINK_ROOT/flvplayer.swf?file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv&autoStart=false' width='175' height='175' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'></embed> would appreciate any suggestions thanks. i was on 1.5 swfobject i did download 2.2 and im guessing all you do is replace the swfobject.js file to upgrade it, but what happened is it gives me this now. Code: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SearchToolbar 1.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; msn OptimizedIE8;ENUS) Timestamp: Sat, 30 Jul 2011 16:31:08 UTC Message: 'SWFObject' is undefined Line: 1283 Char: 1 Code: 0 URI: http://www.mysite/video_admin.php?type=v i dont mind going back to the old version i just need to get this working and im soooooooo lost lol ok another update, this is becomming maddening lol. once i have this line in the header php Code: <script type='text/javascript' src='$CONST_LINK_ROOT/swfobject.js'></script> I never have to use it again as long as they header php is included correct? This is what is driving me nuts, im back on 1.5 and it says its undefined Code: but am in not defining it on this line? ---> var s1 = new SWFObject('player.swf','player','400','300','9'); <script type='text/javascript' src='swfobject.js'></script> <script type='text/javascript'> var s1 = new SWFObject('player.swf','player','400','300','9'); s1.addParam('allowfullscreen','true'); s1.addParam('allowscriptaccess','always'); s1.addParam('flashvars','file=$CONST_LINK_ROOT/movies/$sql_array->vid_id.flv'); s1.write('preview'); </script> Another Update. I am back to the original question. null is null or not an object.. in my search i have found this found a solution. basically Internet Explorer is crappy and doesnt like the setAttribute property so had to change the onchange handler by directly changing the attrbute for the object like so. object.onchange = function() {} i have no idea what they means, does that mean i need to change swfobject.js or does that mean i have to change my xml request. and if it is the swfobject i have no clue what they mean or what lines Hi I've implemented Busybox on a website to display FLV files in a popup player. This works fine, except for the following error in IE (FF is fine) when I close the popup: 'null' is null or not an object I think I've narrowed it down to the following block of code, but am stuck as to what to do from here. Code: var cl = new Element('img',{ 'styles':{ width:'24px', height:'24px', position:'absolute', top:'-20px', right:'-20px', 'z-index':'100000' }, 'src':'bumpbox/closed.png', 'id':'closer' }) cl.addEvent('click',function(e){ e = new Event(e).stop(); bg.dispose(); $(el).getChildren().dispose(); eff2.start({ 'width':[maxw,1], 'height':[maxh,1], 'left': [endleft,middleH], 'top': [endtop, middleV+s] }) }) The IE error is just giving me line number 1 of the php, but the error, I'm sure, lays in the Javascript. Many thanks Hello, I'm working on web apps for a company and unfortunately the websites work in Mozilla, chrom and IE9 but not in IE8. In IE8 the error message "undefined is null or not an object" is pointing to this line: temp = val.replace(/-/g, "/"); That line is inside a function. I'm not sure how to troubleshoot this...any help would be appreciated. Hello all. I am trying to track down why this custom validator is failing with an error that args is undefined. There are two funnctions - one works and one does not. Here they a the bold italicized item is where the error is being generated. Function validHygieneNote works as expected however. Code: function validClothingNote(val,args) { var radio_choice = false; var chks = document.getElementById('clothingNote'); var chks2 = document.getElementsByName('clothingInadequate'); for (counter=0; counter < chks2.length; counter++) { if (chks2[counter].checked){ var rad_val =chks2[counter].value; }} if((rad_val==1)|| (rad_val==2)) { if ((chks.value=="") || (chks.value.length==0) || (chks.value==null)){ args.IsValid=false; } else { args.IsValid = true; } }} function validHygieneNote(val,args) { var radio_choice = false; var chks = document.getElementById('hygieneNote'); var chks2 = document.getElementsByName('hygieneInadequate'); for (counter=0; counter < chks2.length; counter++) { if (chks2[counter].checked){ var rad_val =chks2[counter].value; }} if((rad_val==1)|| (rad_val==2)) { if ((chks.value=="") || (chks.value.length==0) || (chks.value==null)){ args.IsValid=false; } else { args.IsValid = true; } }} Featured Content Slider v2.4 and RSS Display Box (on same page) Tested on Firefox, Chrome, IE7 and IE8, for some reason I get this error on one of the pages, one exact duplicate works fine. 'contentdivs[...].style' is null or not an object I don't have this online. Any ideas? Edit: I thought I solved it but mistaken. rssdisplaybox.js line 25 -> Red slash removed as the image was already in the same folder. Code: this.loadingHTML='<img src="'+rssoutputscript.replace('main.php', '')+' / loading.gif" /> Initializing RSS Display Box...' //Specify HTTML to show while feed is being fetched Featuredcontentslider version is attached. Hi I have the below page. When form is submitted by clicking on the button the function checkform() is executed. Problem is that I am getting a 'entrystartday' is null or not an object error on line Code: if (frm.entrystartday.value == 31) { What is the problem and how can I fix it? Thanks Regards Code: <html> <head> <title>test</title> </head> <body> <form id="theform" action="main.asp" method="post" onsubmit="return checkform()"> <table style="width: 477px;"> <tr> <td style="vertical-align: top;" class="boldwhite"> Start Date </td> <td> <select id="entrystartday" name="entrystartday"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> / <select id="entrystartmonth" name="entrystartmonth"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> / <select name="entrystartyear"> <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="2014">2016</option> <option value="2015">2017</option> </select> <span class="style1"><strong><= Select correct Start Date</strong></span> </td> </tr> </table> <table> <tr> <td class="style2"> <input type="submit" value="save" name="submit" /> </td> </tr> </table> <input type="hidden" name="view" value="<% = theview%>" /> <input type="hidden" value="save" name="a" /> <input type="hidden" value="<% = dateview %>" name="dateview" /> </form> <script type="text/javascript"> function checkform() { document.write("<P>right now 1: " + new Date() + "<P>"); var frm = document.forms["theform"]; if (frm.entrystartday.value == 31) { alert('I am here'); }; document.write("<P>right now 2: " + new Date() + "<P>"); }; </script> </body> </html> Hello, I'm having a TypeError problem. Basically I've got scripts which seem to work fine and don't spit out any errors. There is a contact page... which has a form, and on clicking submit... you can sent to another page generated with a php header and footer and then some custom info based on if you filled everything out correctly or not. In any event, when you get sent to this page it's not really showing up because of some TypeError from the same script that works everywhere else and I can't figure it out. It's specific to the following js. Code: (evaluating 'nav_toggle.addEventListener') which is in the following function Code: // nav toggle function initNavToggle() { // classie toggle var nav = document.querySelector('nav.nav-main'), nav_toggle = document.querySelector('a.nav-toggle'); nav_toggle.addEventListener('click', function(e){ e.preventDefault(); classie.toggle(nav, 'open'); classie.toggle(nav_toggle, 'toggle-back'); }); // toggle burger switch document.querySelector( '.nav-toggle' ).addEventListener( 'click', function() { this.classList.toggle( 'active' ); }); } which pertains to the following html Code: <a href="#" class="nav-toggle">Menu</a> <nav class="nav-main"> <ul> <li><a href="/">A</a></li> <li><a href="/">B</a></li> <li><a href="/">C</a></li> <li><a href="/">D</a></li> </ul> </nav> Is it possible that because the nav html is in the header and being assembled via php that the script is firing before the html exists? Reply With Quote 01-09-2015, 09:56 PM #2 wyclef View Profile View Forum Posts Regular Coder Join Date Feb 2005 Posts 239 Thanks 9 Thanked 0 Times in 0 Posts Well, I guess I just answered my own question because I tried taking the script from the footer and putting it in the header and now everything works. Not understanding what is going on here really. Using FormM@iler | LAMP Application Developer, UI/UX, SEO PHP FormM@iler. Guess hold off looking at this until I examine things further. Reply With Quote 01-09-2015, 10:29 PM #3 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts The code inside a function can't fire until the function is invoked. So where is the function invoked? Where does classie come from? You don't show it. |