You need to share the information somehow, because variables are only available in their function's scope. The simplest way is to define global variables.
var url, id; // global
function addElement(_url, _id) {
url = _url;
id = _id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
function add() {
addUrl(url, id)
alert("id" + id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
Note that they don't need to be global. You can wrap this module into its own scope
(function() {
/// code goes here
})();
Or you can also organize the whole code into an object (encapsulation).
var Adderaddy = {
url: null,
id: null,
addElement: function(url, id) {
this.url = url;
this.id = id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
add: function() {
addUrl(this.url, this.id);
alert("id" + this.id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
};
You need to share the information somehow, because variables are only available in their function's scope. The simplest way is to define global variables.
var url, id; // global
function addElement(_url, _id) {
url = _url;
id = _id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
function add() {
addUrl(url, id)
alert("id" + id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
Note that they don't need to be global. You can wrap this module into its own scope
(function() {
/// code goes here
})();
Or you can also organize the whole code into an object (encapsulation).
var Adder = {
url: null,
id: null,
addElement: function(url, id) {
this.url = url;
this.id = id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
}
add: function() {
addUrl(this.url, this.id);
alert("id" + this.id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
};
You need to share the information somehow, because variables are only available in their function's scope. The simplest way is to define global variables.
var url, id; // global
function addElement(_url, _id) {
url = _url;
id = _id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
function add() {
addUrl(url, id)
alert("id" + id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
Note that they don't need to be global. You can wrap this module into its own scope
(function() {
/// code goes here
})();
Or you can also organize the whole code into an object (encapsulation).
var addy = {
url: null,
id: null,
addElement: function(url, id) {
this.url = url;
this.id = id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
add: function() {
addUrl(this.url, this.id);
alert("id" + this.id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
};
You need to share the information somehow, because variables are only available in their function's scope. The simplest way is to define global variables.
var url, id; // global
function addElement(_url, _id) {
url = _url;
id = _id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
},
function add() {
addUrl(url, id)
alert("id" + id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
Note that they don't need to be global. You can wrap this module into its own scope
(function() {
/// code goes here
})();
Or you can also organize the whole code into an object (encapsulation).
var Adder = {
url: null,
id: null,
addElement: function(url, id) {
this.url = url;
this.id = id;
alert(url);
var main = document.getElementById('mainwidget');
main.innerHTML = "<iframe>...</iframe>";
alert("google");
addUrl(url, id);
}
add: function() {
addUrl(this.url, this.id);
alert("id" + this.id);
document.getElementById("Listsample").innerHTML = "<a>...</a>";
}
};