I'm trying to create a Javascript button inside PHP that will write innerHTML to a span to overwrite the CSS to change a div from display:none to display:block. (Got that?) So far I just can't get the syntax right. At this point in the code, the div (in red) is correctly hidden but the button does not react at all; it doesn't call the function in a way that writes the span contents. The variables are being filled in via a MySQL table. I included commented-out examples above each code so you know what content I'm expecting.

My first step to debug this would be to open the browser console (Firebug if you have it and are using Firefox) and check for errors. It will usually highlight whether you have an error in the syntax or whether it's just not firing. Also consider putting in an alert("1") message (or similar) at stages around the code so that alert boxes pop up when the JS gets to certain points.

To be honest, I would rewrite portions purely because I'm a bit of a stickler for using particular quotes in particular places. For example, I would always use echo 'string'; rather than echo "string"; and I would also always put <script type="text/javascript"> rather than <script type='text/javascript'>. But that's me.

To be honest, there's far too little for me to go on, personally. But if you put an alert() in the section that you expect to fire when you click the button, and it still doesn't fire, then your button looks to be the one at fault. Maybe it's not correctly bound to the event that you are trying to fire?

Try using http://jsfiddle.net/ with the raw JS that is generated (plus the HTML) and let's take a look at it in a way that we can fiddle with and see if we can get it working

If the console is reporting this in the error:" . $i . $ed_i . $url . "That means that the code hasn't been parsed properly. Most likely down to incorrect quotes somewhere along the line. Also, put some \ characters in (in PHP you'll need to use "\" and not '\') to force some linebreaks for readability if you need it