Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,022 members, 7,806,998 topics. Date: Wednesday, 24 April 2024 at 08:21 AM

Help On This Simple Script - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help On This Simple Script (918 Views)

Allow Me To Ask You This Simple Question About Your Business / Help A Java Newbie With This Simple Java Program / Help On This Simple Script (2) (3) (4)

(1) (Reply) (Go Down)

Help On This Simple Script by Setag: 6:40pm On Aug 15, 2015
Function count() { var lbl; document.getElementById('lbl'); for (i=0; i<10; i++) { lbl.innnerHTML+= i+'<br>'; } }
the tags specifically:
<button type='button' onclick='count()'>start counting </button>
<div id='lbl'></div>

i keep getting this error on IE: unable to get property 'innerHTML' of undefined or null reference.
Kinda help fix this and explain..
Cc: dhtml
Re: Help On This Simple Script by JackOfAllTrades: 7:16pm On Aug 15, 2015
You code will not run because you need to assign the object to the variable do this instead
var lbl = document.getElementById('lbl');

2 Likes

Re: Help On This Simple Script by jacob05(m): 7:36pm On Aug 15, 2015
you did not assign value to lbl by mistake.. try indenting your codes too, bugs are, sometimes, easily fixed with proper indentation

function count() {
var lbl = document.getElementById('lbl');
for (i=0; i<10; i++) {
lbl.innnerHTML+= i+'<br>';
}
}



<button type='button' onclick='count()'>start counting </button>
<div id='lbl'></div>

1 Like

Re: Help On This Simple Script by Setag: 10:18am On Aug 16, 2015
jacob05:
you did not assign value to lbl by mistake.. try indenting your codes too, bugs are, sometimes, easily fixed with proper indentation

function count() {
var lbl = document.getElementById('lbl');
for (i=0; i<10; i++) {
lbl.innnerHTML+= i+'<br>';
}
}



<button type='button' onclick='count()'>start counting </button>
<div id='lbl'></div>
Re: Help On This Simple Script by Setag: 10:21am On Aug 16, 2015
jacob05:
you did not assign value to lbl by mistake.. try indenting your codes too, bugs are, sometimes, easily fixed with proper indentation

function count() {
var lbl = document.getElementById('lbl');
for (i=0; i<10; i++) {
lbl.innnerHTML+= i+'<br>';
}
}



<button type='button' onclick='count()'>start counting </button>
<div id='lbl'></div>

sorry, the code is properly indented on the editor.
My mistake here, but on the real script, I initiated the var and assigned value to it.. I keep getting the same error.
I will check it out and get back.
Re: Help On This Simple Script by Setag: 12:57pm On Aug 16, 2015
It worked, saw me mistakes.. Thanks y'all for taking your time..
Re: Help On This Simple Script by Nobody: 1:02pm On Aug 16, 2015
Thank God them don kill the bug.

1 Like

Re: Help On This Simple Script by Kensharval(m): 9:01pm On Aug 18, 2015
If you wish to have a professional shared hosting quality in a free hosting package, come and host with 000webhost.com and experience the best service you can get absolutely free. Founded in December 2006, 000webhost.com has a trusted free hosting members base of over 60,000 members and still counting! Offering professional quality hosting, support, uptime and reliability, we have a great community of webmasters, you'd love to be a part of! Register now and get it all free: *** 1500 MB of disk space *** 100 GB of data transfer *** PHP and MySQL support with no restrictions *** cPanel control panel *** Website Builder *** Absolutely no advertising! Join us now: http:// www.000webhost.com/876430.html

(1) (Reply)

Development Of Apps / We Don’t Just Build You An E-commerce Site….we Make Your Business Grow Globally / Do You Have A Desktop?,why Not Be A Guru In Web Design And Other Ict Proggrammin

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.