I have this code:
<script type="text/javascript">
function js() {
var getJs = document.getElementById("jogo");
if (JS == true) { //if button JS is pressed - it is correct?
< script type = "text/javascript"
src = "file1.js" >
} else < script type = "text/javascript"
src = "file2.js" >
</script>
}
</script>
it doesn't work. I gave two buttons, if the first is pressed, file1.js should be loaded. In case the second one is pressed, file2.js should be loaded.
How can I do that?
if (JS == true)dosent mean it being pressed, it simply mean that element is exist in the DOM and why dont u just include all the script and then call the appropriate function based on the existence of the JSevalas solution unless it's the only way to do. Bad guides would suggest code likeeval("document."+id+".value="+numericValue). That is highly insecure!