Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,170 members, 7,953,628 topics. Date: Thursday, 19 September 2024 at 09:11 PM

Could This Basic Code Be Malfunction? - Programming (2) - Nairaland

Nairaland Forum / Science/Technology / Programming / Could This Basic Code Be Malfunction? (3174 Views)

Help Me Cross Check My Visual Basic Code / Need Help On This Basic Php / Need Help With This Basic Php (2) (3) (4)

(1) (2) (Reply) (Go Down)

Re: Could This Basic Code Be Malfunction? by Nmeri17: 8:09pm On Jul 29, 2015
blueyedgeek:
Sorry, I wasn't able to reply earlier. Search for proffesional javascript for web developers. It's for both beginners and experts alike and it's the most understandable and comprehensive book I've come across .
you don't say I ditched Eloquent for this book and by His grace, I can live to narrate my ordeal embarassed

that book basically requires doctorate degree level of knowledge in Complex English and Comprehension, before we even start discussing js kpaakpaa. by the time you search up the definition of the terms they used, you've forgotten the context it was used in. now eloquent is orgy cheesy
Re: Could This Basic Code Be Malfunction? by blueyedgeek(m): 8:19pm On Jul 29, 2015
Nmeri17:
you don't say I ditched Eloquent for this book and by His grace, I can live to narrate my ordeal embarassed

that book basically requires doctorate degree level of knowledge in Complex English and Comprehension, before we even start discussing js kpaakpaa. by the time you search up the definition of the terms they used, you've forgotten the context it was used in. now eloquent is orgy cheesy
Really? Both are great books sha. I would recommend head first Javascript 2nd edition but not everyone would like the style employed by the authors. For anyone still looking for js books, go to http://jsbooks.revolunet.com they have a great listing and everything is sorted based on difficulty level (beginner, intermediate and advanced)
Re: Could This Basic Code Be Malfunction? by paranorman(m): 2:02pm On Oct 24, 2015
Here's the script:

if (document.getElementById('hid').checked) {
document.getElementById('hidDiv').style.display = 'none';
}


the tags:

<div id = "hidDiv">
This paragraph is meant to be hidden
</div>


<input type = "checkbox" id = "hid" />

error messgage: unable to set property "checked" of undefined or null referenced.

I just wrote out the tags out specifically here for short.

Confused oh.

dhtml18
Re: Could This Basic Code Be Malfunction? by Nobody: 7:24pm On Oct 24, 2015
Try this one:

<script>
window.onload=function() {

document.getElementById('hid').onclick=function() {
disp= this.checked? 'block' : 'none';

document.getElementById('hidDiv').style.display = disp;
}

}
</script>


<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>


<input type = 'checkbox' checked id = 'hid' />
Re: Could This Basic Code Be Malfunction? by paranorman(m): 8:01pm On Oct 24, 2015
dhtml18:
Try this one:

i have questions though:
why does the window.onload functions have to accomadate the document.getElementById(""wink.onclick = "" method before it works?

You didn't explain why I am getting the error mesage because tThe code I wrote(which you corrected) works wel on the console.


The element with id 'hid' is a checke list, why use the onclick event handler in your code? I think is only cool with buttons
Re: Could This Basic Code Be Malfunction? by paranorman(m): 8:03pm On Oct 24, 2015
paranorman:

i have questions though:
why does the window.onload functions have to accomadate the document.getElementById(""wink.onclick = "" method before it works?

You didn't explain why I am getting the error mesage because tThe code I wrote(which you corrected) works wel on the console.


The element with id 'hid' is a checke list, why use the onclick event handler in your code?
Re: Could This Basic Code Be Malfunction? by Nobody: 2:00pm On Oct 25, 2015
Version 1:

<script>
window.onload=function() {

document.getElementById('hid').onclick=function() {
disp= this.checked? 'block' : 'none';

document.getElementById('hidDiv').style.display = disp;
}

}
</script>


<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>


<input type = 'checkbox' checked id = 'hid' />

Version 1B (jQuery Extended):



<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>

<input type = 'checkbox' checked id = 'hid'/>

<script src="http://code.jquery.com/jquery-1.10.2.js"></script>

<script>
$(function() {

$('#hid').click(function() {
disp= this.checked? 'block' : 'none';

$('#hidDiv').css({display:disp});

});

});
</script>




Version 2:


<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>


<input type = 'checkbox' checked id = 'hid' />

<script>
document.getElementById('hid').onclick=function() {
disp= this.checked? 'block' : 'none';

document.getElementById('hidDiv').style.display = disp;
}
</script>

Version 3:


<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>


<input type = 'checkbox' checked id = 'hid' onclick="hideEl(this)"/>

<script>
function hideEl(el) {
disp= el.checked? 'block' : 'none';

document.getElementById('hidDiv').style.display = disp;
}
</script>

Version 4:


<div id = 'hidDiv'>
This paragraph is meant to be hidden
</div>


<input type = 'checkbox' checked id = 'hid' onclick="disp= this.checked? 'block' : 'none';document.getElementById('hidDiv').style.display = disp;"/>
Re: Could This Basic Code Be Malfunction? by Nobody: 2:06pm On Oct 25, 2015
paranorman:

i have questions though:
why does the window.onload functions have to accomadate the document.getElementById(""wink.onclick = "" method before it works?

You didn't explain why I am getting the error mesage because tThe code I wrote(which you corrected) works wel on the console.


The element with id 'hid' is a checke list, why use the onclick event handler in your code? I think is only cool with buttons
onclick is an event handler that is bound to that checkbox so that whenever the checkbox is clicked, the code in the event handler are triggered.

If you compare the jQuery version with the version 2 above, you will see a lot of similarities!

(1) (2) (Reply)

How To Say "Hello World" In Different Programming Languages / How Profitable Is Android App Development In Nigeria? / Arduino Visual Embedded Programming With Flprog

(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. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.