3D,
//This is the bad way
function func1(str){
document.getElementById("txtHint").innerHTML = 'Graph type: <select id="sel" name="sel" onchange="func2(\'' + str + '\')"><option value="1">1</option><option value="2"> 2</option></select>';
}
//This is preferred
function func1(str){
document.getElementById("txtHint").innerHTML = 'Graph type: <select id="sel" name="sel"><option value="1">1</option><option value="2"> 2</option></select>';
document.getElementById("sel").onchange = function(){
func2(str);
};
}
For a number of reasons, event handlers are better attached in javascript than in HTML.Airshow
Airshow
WiFi Lounge Lizard
2,683 posts since Apr 2009
Reputation Points: 321
Solved Threads: 372