If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

In google chrome open tools -> developer tools. New windows will appear, go to resources and find file that contains this JS code. It should say if there was an error. If there was no error then click that button of yours so it executes your JS function and then see if an error occurs.

An easier way to check if this is a syntax error is to change

PHP Code:

$words_unedited = $info['cz'];

to

PHP Code:

$words_unedited = "If you can see this then there is a syntax error.";

*BUT*, when the user clicks on that button, the *ENTIRE HTML PAGE WILL DISAPPEAR*, to be replace with *ONLY*

Code:

ANY TEXT AT ALL

Even the JavaScript that was used to do the document.write will be gone.

Why? Because if you use document.write *OTHER* than during the CREATION of the HTML of the page, you *automatically* first do the equivalent of window.open( ) of the current page, which means you are WIPING OUT all content of the page and replacing it with whatever document.write creates.

This is only *ONE* of the reasons that document.write is considered very very obsolete! There are a very few reasons for using it, but they are much more advanced than have anything to do with responding to a mouse click or similar. As a good rule: Until and unless you ever discover that there is NO OTHER WAY to accomplish what you want, do *NOT* use document.write. And of course the same applies to alert( ) and confirm( ).

****************
On a completely different topic:

There is no practical difference between

Code:

echo "$words_unedited";

and

Code:

echo $words_unedited;

The quote marks in the first case will simply disappear. So the end result in HTML will be identical.

If you aren't sure that you PHP code is doing the right thing, then DEBUG DEBUG DEBUG.

In this case, the FIRST thing to do is bring up the web page in your browser. Then:
-- click on the VIEW menu of your browser
-- click on the SOURCE or PAGE SOURCE menu item
-- look at the HTML that appears, which is the HTML *as the browser sees it*.
-- find your myFunction code in that HTML
-- see if it looks like it is, indeed, getting the expected string from PHP.

In google chrome open tools -> developer tools. New windows will appear, go to resources and find file that contains this JS code. It should say if there was an error. If there was no error then click that button of yours so it executes your JS function and then see if an error occurs.

An easier way to check if this is a syntax error is to change

PHP Code:

$words_unedited = $info['cz'];

to

PHP Code:

$words_unedited = "If you can see this then there is a syntax error.";

I can see the text:

"If you can see this then there is a syntax error.";

I check that before, the problem I have is that the variable $words_unedited is an array (I think) and javascript is not able to print it as a string (at least I don`t know how to do it).

*BUT*, when the user clicks on that button, the *ENTIRE HTML PAGE WILL DISAPPEAR*, to be replace with *ONLY*

Code:

ANY TEXT AT ALL

Even the JavaScript that was used to do the document.write will be gone.

Why? Because if you use document.write *OTHER* than during the CREATION of the HTML of the page, you *automatically* first do the equivalent of window.open( ) of the current page, which means you are WIPING OUT all content of the page and replacing it with whatever document.write creates.

This is only *ONE* of the reasons that document.write is considered very very obsolete! There are a very few reasons for using it, but they are much more advanced than have anything to do with responding to a mouse click or similar. As a good rule: Until and unless you ever discover that there is NO OTHER WAY to accomplish what you want, do *NOT* use document.write. And of course the same applies to alert( ) and confirm( ).

****************
On a completely different topic:

There is no practical difference between

Code:

echo "$words_unedited";

and

Code:

echo $words_unedited;

The quote marks in the first case will simply disappear. So the end result in HTML will be identical.

If you aren't sure that you PHP code is doing the right thing, then DEBUG DEBUG DEBUG.

In this case, the FIRST thing to do is bring up the web page in your browser. Then:
-- click on the VIEW menu of your browser
-- click on the SOURCE or PAGE SOURCE menu item
-- look at the HTML that appears, which is the HTML *as the browser sees it*.
-- find your myFunction code in that HTML
-- see if it looks like it is, indeed, getting the expected string from PHP.

The problem is clearly in $words_unedited = $info['cz']; not in document.write