I made a little game in javascript using checkboxes. Checkboxes are small and fiddly so I want to replace them with images. I'm having a problem at the moment with quite a large string. My prog is a bit big to post but here is the function I'm having probs with:
function DrawBit(state, bit){ var str = "b"+bit; if (state == 0) { state[bit]=1; UpdateText("'b"+bit+"'", "<img src='On.PNG' onclick='UpdateText("+str+", DrawBit(1, "+bit+"))' />"); } else { state[bit]=0; UpdateText("'b"+bit+"'", "<img src='Off.PNG' onclick='UpdateText(" +str+ ", DrawBit(0, "+bit+"))' />"); }}
Basically when the image is clicked I want to change its state and picture. My problem is where you see the: +str+It seems that here I would need a third seperate set of qoutes on top of the ' and " symbols. Do these things exist? Or does anyone know how I could get this to work, thats if its possible to get it to work. Oh yeah and just in case it helps heres the UpdateText() function:
function UpdateText(area, change_to){ document.getElementById(area).innerHTML = change_to;}
And heres one of the original lines that gets wrote in the HTML file:
document.write("<td><div id='b0'><img src='Off.PNG' onclick='UpdateText(", '"b0"', " , DrawBit(1, 0))' /></div></td>");