« first day (3948 days earlier)      last day (1007 days later) » 

mr5
3:52 AM
 
4:27 AM
 
 
4 hours later…
8:38 AM
Was wondering if someone could explain this example w3schools.com/html/tryit.asp?filename=tryhtml_elem_output
 
@user31782 w3schools is a terrible resource. We suggest using MDN.
 
one sexcond
For one I disagree with you, its a good resource, second, how are they using javascript without script tag in oninput="x.value=parseInt(a.value * 2)+parseInt(b.value)
And how a and b refer to html elements? They didnt use getElementById.
 
9:00 AM
It's a simple calculation. Range input value + input value = total value. Javascript is available in any browser. They are using inline javascript in that example ( not the best approach ) . And yes, W3schools is NOT a good resource ( it is good only for basic stuff ) . Use MDN as James suggested
 
@MihaiT Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@MihaiT if they are using inline js, then wheres the script tag and how come a and b refer to input elements without being assigned as a = getElementById("#a")?
If something is for basic stuff, that doesnt make it a bad resource. I've seen cases where MDN doesnt explain a point, which is explained on w3school
 
9:25 AM
@user31782 I suspect it's a mix of 1.: the event handler oninput get's the form as this so inside that scope accessing undefined vars like x, a, b will try this.x/this.a/this.b and 2.: form elements can be accessed as property on the form
so inside that handler on that form element it's pretty much the same as: oninput="document.forms[0].elements['x'].value=parseInt(document.forms[0].elements['a'].value)+parseInt(document.forms[0].elements['b'].value)"
in any case.. it's a horrible example
 
If this is taken as document.forms[0] then how does this.x is translated to this.elements["x"]
 
9:54 AM
@user31782 second paragraph in the link I wrote above developer.mozilla.org/en-US/docs/Web/API/…
 
10:10 AM
it might be good to mention that this expression will only work inline, a script side handler needs to reference the form which makes it more explicit like form.oninput = function() {this.x.value = parseInt(this.a.value) + parseInt(this.b.value)}
 
11:06 AM
@user31782 Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
1 message moved to Trash can
 
@makadev thanks mate, you are correct. I ran a test in script tag:

document.getElementsByTagName("form")[0].oninput = function(e){
		console.log(e,a,b,this);
		console.log(this.a, a.value, a);
}

It pops out `a` as the `input` element. Furthermore, I guess inline code acts like`oninput = "I act like a function"
@makadev why can we access a and b, without even using this.a and this.b?
 
 
2 hours later…
1:13 PM
Why does every JS beginner guide start with the DOM?
I think it should be introduced later on
 
 
2 hours later…
3:31 PM
@JBis Written by beginners for beginners. All you need to do with JS is to make those fancy DHTML pages, right?
 
It is not a part of JS tutorial
Its HTML form section which explains how <output> comes handy.
It looks like they copied that section from MDN: developer.mozilla.org/en-US/docs/Web/HTML/Element/…
Well.. funny now that makes MDN a beginner site as well :-)
 
hi'
*hi
 

« first day (3948 days earlier)      last day (1007 days later) »