I have this bit of javascript and php:
function change(){
var heading = "<?= $heading ?>";
var description = "<?= $description ?>";
var valid = "<?= $valid ?>";
var background = "<?= $background ?>";
alert("hi");
switch(background){
case 1:
document.getElementById('main').style.backgroundImage = "(url"img/bg1.jpg")";
break;
case 2:
break;
case 3:
break;
default:
break;
}
}
If I remove the case 1, the line: document.getElementById('main').style.backgroundImage = "(url"img/bg1.jpg")"; the function will work, I’ll get the hi alert. But if its in there it doesn’t work at all. But I’ve used that line of code before and its worked, why does it cause this script to stop working?
TIA
Try replacing that line with: