PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have tried double quotes and escaping twice /"/" because I thought javascript needed to escape div quotes as well and have tried concatinating in certain ways and I cannot figure out what to do.
I appreciate the response however, it did not work. The reason I removed the echo and " on each end is because it is within a larger echo statement. The reason I left ; in is because that is ending the javascript command which you forgot to add. Are you sure that class='something' will work? you do not need to somehow escape and incorporate double quotes "?
When you are debugging something that isn't working, it's best not to "simplify" it, either when seeking help, or even for your own analysis, because you just MAY be obscuring the heart of the problem.
The way to analyze messy quoted string issues like this is to think like the parser 'thinks'. Here you're trying to create a string for PHP to send to the browser, that contains further strings that will be interpreted by Javascript. So start with the 'echo' and proceed through the entire string. If you begin the string with a double-quote, the parser will treat the next double-quote it sees as the end of the string, if it's not escaped, so if you want to use a double-quote to be passed to the Javascript string, it must be escaped. There is no reason to escape single-quotes in such a scenario. You're right about the ending semicolon for the Javascript command, that slipped my attention. Have you looked at the string this produces in the HTML source? That's what counts. You should be able to see there what else may be wrong, and work backward to make it come out right.
The code does not execute at all leaving the test div blank. The problem is, this seems generally what I wanted to echo. I am pretty positive it is possible to project div content using innerHTML
tried that in plain html, and it doesn't even work. I think javascript may be having a problem. The thing that gets me is that I have seen illustrated examples using innerHTML to post div content and spans.
scarface222 wrote:The code does not execute at all leaving the test div blank. The problem is, this seems generally what I wanted to echo. I am pretty positive it is possible to project div content using innerHTML
I don't see anything wrong there. So now it's not a PHP problem, it's a Javascript problem. You might want to post the Javascript in our Javascript forum. No need to involve PHP at all, just show your entire JS function and the associated HTML. I'm sure someone will give you a hand with it.
I appreciate your time califdon, it was the weirdest problem although your insight into going to test through html led me to it. For some reason....I had to delete all the spaces between each tag and subsequent content and then it worked. Do you have any insight into why this would be? I did not think javascript was sensitive to spacing.
scarface222 wrote:I appreciate your time califdon, it was the weirdest problem although your insight into going to test through html led me to it. For some reason....I had to delete all the spaces between each tag and subsequent content and then it worked. Do you have any insight into why this would be? I did not think javascript was sensitive to spacing.
Depends on where the spacing is. Generally, spaces are required anyplace where the parser would be confused by not knowing where a command or a tag or something ends. Glad you found the problem.