so in a search of working method to change div content after an hour i came back to w3school website and copied code from there , and that bloody thing still doesn't work. Am i doing it wrong ?
button
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
Your code works fine in the latest FireFox and IE8.
Compare the HTML below with what your rendered HTML to see what you might have wrong. Have you checked the error console to see if it is throwing an error?
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Demo</title></head><body><div class="mainmenu"><button onclick="displayDate()" id="buttons" type="button">asdasd</button></div><div id="teams"><p id='test'>asdasd</p></div></br><script type="text/javascript">
function displayDate() {
document.getElementById("test").innerHTML=Date();
}
</script></body></html>
Your code works fine in the latest FireFox and IE8.
Compare the HTML below with what your rendered HTML to see what you might have wrong. Have you checked the error console to see if it is throwing an error?
I created an html file with the same code and it works. But when i do it in .php with echo it doesn't work, in fact i dont have any .html files only one .php and one .css in my "working directory". And i dont know how to open error console.
// div block
echo"
<div id=\"teams\">
<p id='test'>asdasd</p></div>
";
?>
Albert Einstein ~ "Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Things To help you on this Site
1. Place all php code in [php] Tags 2. Place all html code in [html] Tags 3. Remember to mark all your Threads Resolved using thead tools at the top when your problem is solved
BTW, when I say "rendered HTML" I am referring to you doing a "View Source" in your web browser to see what your HTML actually looks like. If the issue is an extra \ somewhere in the IDs, you would see it in "View Source".
Error Console is typically in something named like "Developer Tools" which is typically accessed by pressing [F12] in your browser. If you are using FireFox, I strongly encourage installing the FireBug add-on.
Consider using HEREDOC quoting so that you don't have to worry about escaping quotes.
PHP Code:
<?php
echo <<<END
<p id="do_not_need_slashes">This is a test</p>
<p>And it interpolates $variables just like double quotes</p>
<p>You can indent all you want, EXCEPT the ending string can not have ANY leading white-space:</p>
END;
?>
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
It works everywhere like that why shouldn't it work with \'test\' in particular ?
Originally Posted by nap0leon
Ahh - a php issue, not a javascript issue.
BTW, when I say "rendered HTML" I am referring to you doing a "View Source" in your web browser to see what your HTML actually looks like. If the issue is an extra \ somewhere in the IDs, you would see it in "View Source".
Error Console is typically in something named like "Developer Tools" which is typically accessed by pressing [F12] in your browser. If you are using FireFox, I strongly encourage installing the FireBug add-on.
did that , thankyou
Originally Posted by NogDog
Consider using HEREDOC quoting so that you don't have to worry about escaping quotes.
PHP Code:
<?php echo <<<END <p id="do_not_need_slashes">This is a test</p> <p>And it interpolates $variables just like double quotes</p> <p>You can indent all you want, EXCEPT the ending string can not have ANY leading white-space:</p> END;
Bookmarks