As part of an ajax call I want to add this javascript function listed between a script tag to my document. The ajax call works fine except it cuts out this portion of my document.
<script language="javascript">
window.onload = function(){
var input = document.getElementById('tid-acc');
document.getElementById('rule-type').onchange = function() {
var v
al = this.value;
if (val == 'tid and acc') {
input.style.display = 'inline';
}
else {
input.style.display = 'none';
}
};
}
</script>
What am I doing wrong? For reason I won’t go into, I need to execute this function dynamically on Ajax call. Thanks in advance.
Here is a good article about it: Global eval. What are the options?
Article also compares how famous js libraries do it:
Here is how Mootools 1.3.2 does it: