d3v4 — 2011-03-31T05:07:43-04:00 — #1
Is it possible, from inside a function, to access a variable that is inside another function?
Specifically, what I'm doing here is that when a user enters a value in the text field "one", the doubled value is inserted into text field "two". I would like to take the value that was entered in the first text field and use it to calculate something in another text field. Here's the code:
I would like to use $val1 final value in the second function. Is this possible?
chris_upjohn — 2011-03-31T06:18:07-04:00 — #2
You could simply just add a global var before the events
var $val1 = false;
d3v4 — 2011-03-31T07:07:57-04:00 — #3
Believe me, I did this but it didn't work xD Now it works lol
Anyways, just out of curiosity, is this the only way to access the variable or are there other ways?
chris_upjohn — 2011-03-31T07:50:50-04:00 — #4
From my memory this is the only way i know of storing variables within the jQuery DOM ready function for the local internal scope.
d3v4 — 2011-03-31T07:56:45-04:00 — #5