JavaScript - .length Is Null
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 Similar TutorialsHi, 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');"> Hi, 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 My array is like so... shp[0][0] = 5; shp[0][1] = "A5"; shp[0][2] = "A2"; shp[0][3] = "A1"; shp[0][4] = "A4"; shp[0][5] = "A3"; shp[1][0] = 4; shp[1][1] = "C3"; shp[1][2] = "C4"; shp[1][3] = "C1"; shp[1][4] = "C2"; shp[2][0] = 3; shp[2][1] = "E1"; shp[2][2] = "E3"; shp[2][3] = "E2"; shp[3][0] = 3; shp[3][1] = "G3"; shp[3][2] = "G2"; shp[3][3] = "G1"; shp[4][0] = 2; shp[4][1] = "I2"; shp[4][2] = "I1"; the results I am after is... shp[0][0] = 5; shp[0][1] = "A1"; shp[0][2] = "A2"; shp[0][3] = "A3"; shp[0][4] = "A4"; shp[0][5] = "A5"; shp[1][0] = 4; shp[1][1] = "C1"; shp[1][2] = "C2"; shp[1][3] = "C3"; shp[1][4] = "C4"; shp[2][0] = 3; shp[2][1] = "E1"; shp[2][2] = "E2"; shp[2][3] = "E3"; shp[3][0] = 3; shp[3][1] = "G1"; shp[3][2] = "G2"; shp[3][3] = "G3"; shp[4][0] = 2; shp[4][1] = "I1"; shp[4][2] = "I2"; so it sorts all from the second part of the array to the end in alpha-numerical order. I tried the following but i get errors about Cannot call method 'unshift' of undefined. // var shp; var shpbk; var shpbktemp; // shpbk = shp.slice(); shpbktemp[0] = shpbk[0][0]; shpbk[0] = shpbk[0].shift; shpbk[0] = shpbk[0].sort; shpbk[0] = shpbk[0].unshift(shpbktemp[0]); shpbktemp[1] = shpbk[1][0]; shpbk[1] = shpbk[1].shift; shpbk[1] = shpbk[1].sort; shpbk[1] = shpbk[1].unshift(shpbktemp[1]); shpbktemp[2] = shpbk[2][0]; shpbk[2] = shpbk[2].shift; shpbk[2] = shpbk[2].sort; shpbk[2] = shpbk[2].unshift(shpbktemp[2]); shpbktemp[3] = shpbk[3][0]; shpbk[3] = shpbk[3].shift; shpbk[3] = shpbk[3].sort; shpbk[3] = shpbk[3].unshift(shpbktemp[3]); shpbktemp[4] = shpbk[4][0]; shpbk[4] = shpbk[4].shift; shpbk[4] = shpbk[4].sort; shpbk[4] = shpbk[4].unshift(shpbktemp[4]); 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 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 wonder is there any javascript to calculate IP length For example I have Start ADDR: VLAN_ADDR which is: 10.52.28.0 Stop ADDR: VLAN_LAST which is 10.52.29.254 As I know:result is 512 or another example: Start ADDR: VLAN_ADDR which is: 10.52.64.11 Stop ADDR: VLAN_LAST which is 10.52.64.15 As I know:result is 5 How to count it in javascript code ? Results are "numbers" Best regards Leos. Overview: Order entry project. I am using an iFrame to pull external forms that I can not change. Once our employee enters in the information and submits I would like to redirect the existing window to a new page. I've tried many variations of: Code: <script type='text/javascript'> function iHistory() { var hist=history.length; if (hist>1) { parent.window.location = "orderentry.php"; } } </script> Since I have no control of the external form I have been using OnLoad() in the iFrame tag to call iHistory(). The script works great unless the browser history is >1 If possible, I would like to also setup like a 5 or 10 second delay so the employee can see the framed confirmation page before redirect. So the function needs to check current history.length, when that changes delay 5-10 seconds and redirect parent window to orderentry.php I want to use the new keyword to instantiate an object. The catch is I want to pass in variable length arguments. Given: Code: function Foo () { this.args = Array.prototype.join.call (arguments); } var args = ["arg0", "arg1", "arg2"]; The following don't work (though I understand why): Code: new Foo.apply (null, args); new (Foo.apply (null, args)); (new Foo).apply (null, args); Any ideas on how to do what I want without modifying Foo's source code? Ok I have a textarea field that is validated by Js, this textarea can and will contain the newline character Code: \n so I validate in JS Code: if(textareaname.value.length < 200) this hten goes through to my php where i also check before I place in to the Database using MYSQL Code: if( strlen($_POST['textareaname']) < 200 ) but my php is giving me a different string length from my javascript. It looks as if Javascript is counting a newline as 1 character and php is treating it as 2. I have checked my slashes, I have used various REgex to check these data amounts. I have also Googled around and there doesnt seem much around. Any ideas? Any suggestions as to how I can make php and javascript treat a newline as the same amount of characters? Thanks in advance. function checkValidFormInput() { if (document.getElementsByName('customerName').value != '') { document.getElementById('customerNameImg').innerHTML = '<img alt="Valid" src="images/greenTick.png">'; } else { document.getElementById('customerNameImg').innerHTML = '<img alt="Invalid" src="images/redX.png">'; } if (document.getElementsByName('customerEmail').length > 0) { document.getElementById('customerEmailImg').innerHTML = '<img alt="Valid" src="images/greenTick.png">'; } else { document.getElementById('customerEmailImg').innerHTML = '<img alt="Invalid" src="images/redX.png">'; } } I'm trying to figure out how to add a length paramater to this function. Not quite sure how to do it. here's what I tried: Code: var phone = document.getElementById('phone'); if(isNumericdashes(phone, "Please enter a valid phone number")){ return true; } function isNumericdashes(elem, helperMsg){ var numericExpression = /^[0-9\(\)-]+$/; if(elem.value.match(numericExpression) &&(elem.length > 9)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } I write code using ext js,openlayers and GeoExt for measuring length and area ,it is working inside inside of india in the world map but this measure tool is not working outside of india in the world map. My code for Measure length: To Load map: var projWGS84 = new OpenLayers.Projection("EPSG:4326"); var projSphericalMercator = new OpenLayers.Projection("EPSG:900913"); var bounds = new OpenLayers.Bounds(68.137, 6.783, 97.336, 37.086); bounds.transform(projWGS84, projSphericalMercator); map.maxExtent = bounds; var gphy = new OpenLayers.Layer.Google("Google Street", { 'sphericalMercator':true //maxExtent: new OpenLayers.Bounds(-20037508, -20037508,20037508, 20037508) } ); var osmLayer = new OpenLayers.Layer.OSM(); // Add the background images via WMS // Add the background images via WMS //map.addLayer(bglayer); // map.addControl(new OpenLayers.Control.MousePosition()); map.addLayers([gphy, osmLayer]); Measure Length: Measure = new Ext.SplitButton({ text:"Measure", iconCls:"icon-measure-length", toggleGroup:"navigate", group: "navigate", enableToggle:true, allowDepress:false, handler: function(button, event) { // allowDepress should deal with this first condition if(!button.pressed) { button.toggle(); } else { button.menu.items.itemAt(activeIndex).setChecked(t rue); } }, listeners: { toggle: function(button, pressed) { // toggleGroup should handle this if(!pressed) { button.menu.items.each(function(i) { i.setChecked(false); }); } }, render: function(button) { // toggleGroup should handle this Ext.ButtonToggleMgr.register(button); } }, menu: new Ext.menu.Menu({ items: [ new Ext.menu.CheckItem( new GeoExt.Action({ text: "Length", toggleGroup:"navigate", iconCls:"icon-measure-length", group: "navigate", enableToggle:true, allowDepress:false, map: map, control: new OpenLayers.Control.Measure(OpenLayers.Handler.Path , { eventListeners: { measu function(evt) { Ext.MessageBox.show({ title: 'Line length :', buttons: Ext.MessageBox.OK, width:200, msg:"Line Length: " + evt.measure.toFixed(2) + " " + evt.units }); } } }) }) ) } }) }) ) ] }) }) All, I have the following code: console.log("My num is: " + num); console.log("My lat is: " + lat); console.log("My lat length is: " + lat.length); console.log("My long is: " + long); When I get the output, I get the following: My num is: {"1":1,"2":2} My lat is: {"1":"40.59479899","2":"41.4599860"} My lat length is: 36 My long is: {"1":"-75.5549650","2":"-87.596430"} I'm confused on why the length is saying 36 when it's obviously two and the other output shows that??? Hi, I'm a JS beginner and I find looping through arrays with for/in is very easy. Yet I find lots of code examples where array length is used instead of for/in and I'm thinking to myself, why do it this (somewhat) hard(er) way? Maybe I'm missing something... Thanks for your help. How can I call a function in javascript like: Code: var x = string.Length ??? and not like: Code: var x = Length(string); (just for arguments sake) (Also please don't suggest JQuery, I'm doing this to learn!) Thanks! I have a string of text, and starting from a particular spot (known to be a number), I want to find the length of that number. Here's what I have: Code: ... var start = [...predetermined...] var end = 0; while (!isNaN(sourceCode.charAt(start + end))){ endCurrent++; } var myNum = sourceCode.substr(start, end) * 1; So let's say var sourceCode = "alkdjabjasdsdf-53 dnalsdb..."; , startCurrent will already be at the "5" and I want to be able to extract the "53". What I have works, but it seems cumbersome... Any advice? Hey I was just wondering how I could do this... I currently have this Code: <span id="span_1">Title</span> What I want to know is if the span is something like 240px in width how can I make it so if the text inside the span tag is to long and puts the text onto a second line how can i make a cut off point in the text to stop the text moving to a new line and adding '...' if the text is to long?? Hi all, I have a free script I have downloaded and I can't figure out how to edit it so that I can change the color of the text to whatever I want it to be and also so that the length of the scrolling text (I am not sure if scrolling is the right term) can be changed. For some reason the text does not go all the way to the end of the page on the right it stops quite a way before. Here is the code: Code: <script language="JavaScript1.2"> <!-- /* Typing Scroller For full source code, usage terms, and 100s more scripts, visit http://dynamicdrive.com */ //Secify scroller contents var line=new Array() line[1]="Testing testing one to three and you can test some more." line[2]="Always testing always testing" line[3]="Trying to test some more and some more again" line[4]="second to last bit of testing." line[5]="Testing text that is just testing one more time" //Specify font size for scoller var ts_fontsize="13px" //--Don't edit below this line var longestmessage=1 for (i=2;i<line.length;i++){ if (line[i].length>line[longestmessage].length) longestmessage=i } //Auto set scroller width var tscroller_width=line[longestmessage].length lines=line.length-1 //--Number of lines //if IE 4+ or NS6 if (document.all||document.getElementById){ document.write('<form name="bannerform">') document.write('<input type="text" name="banner" size="'+tscroller_width+'"') document.write(' style="background-color: '+document.bgColor+'; color: '+document.body.text+'; font-family: arial; font-size: '+ts_fontsize+'; font-weight:bold; border: medium none" onfocus="blur()">') document.write('</form>') } temp="" nextchar=-1; nextline=1; cursor="" function animate(){ if (temp==line[nextline] & temp.length==line[nextline].length & nextline!=lines){ nextline++; nextchar=-1; document.bannerform.banner.value=temp; temp=""; setTimeout("nextstep()",1000)} else if (nextline==lines & temp==line[nextline] & temp.length==line[nextline].length){ nextline=1; nextchar=-1; document.bannerform.banner.value=temp; temp=""; setTimeout("nextstep()",1000)} else{ nextstep()}} function nextstep(){ if (cursor==""){ cursor=""} else if (cursor==""){ cursor=""} else if (cursor==""){ cursor=""} else if (cursor==""){ cursor=""} nextchar++; temp+=line[nextline].charAt(nextchar); document.bannerform.banner.value=temp+cursor setTimeout("animate()",25)} //if IE 4+ or NS6 if (document.all||document.getElementById) window.onload=animate // --> </script> I have been trying to figure this out for about 2 hours but since I am a 100% novice with javascript I have not got very far. Any help would be gratefully recieved. |