I'm not sure if this is even possible, but here goes.

I have a PHP function called code\_check\_result($code\_name). It checks in the database and returns a bunch of information regarding the supplied code's name.

The name of the code is found within a span tag in the page. I've made a javascript function that opens a new window which should then execute the PHP function. However, the variable needed in the PHP function is stored in a jquery var as I have selected the span tag and stored whatever's inside.

Below you can see the part of the code where the window is created (just the part with the PHP function).

```
myWindow.document.write('Tjek: ' + code_name + '</br></br></br></br><?php code_check_result("kode2"); ?>');

```

"kode2" is the actual name of a code. The above works exactly as it's supposed to. However, if I substitute the "kode2" string with the javascript variable, 'code\_name', it doesn't work. Like this:

```
myWindow.document.write('Tjek: ' + code_name + '</br></br></br></br><?php code_check_result("' + code_name + '"); ?>');

```

The first occurence of code\_name writes it to the page, but the second one within the PHP function doesn't work.

I'm pretty sure this is just because the PHP is executed before the 'code\_name' variable is written as a string. But I'm not entirely sure.

So, I'd appreciate it if you could either help me figuring out how to do this, OR tell me to abandon this idea because it's not possible and then give me some pointers as to how else to solve this.