Jump to content

php code not executed when put in javascript


forzatio

Recommended Posts

Hi, I have some php code that I want to echo inside a javascript, when clicking the item with javascript attached it should display the echo on my page.

It works fine on my localhost php version 5.20 , but on some servers online that use version 4.3.11 and 4.4.4 , It just doesn't work and the page stops loading when it reaches the javascript.

Are those earlier versions not capable of doing that ?, how can I else reach the same goal.
Link to comment
Share on other sites

Please post you code. We can't help you if we don't see what you're attempting.

Actually, since Javascript runs on the client (i.e. Browser) and PHP runs on the Server, what you're attempting shouldn't work at all unless you are using AJAX techniques.

Ken
Link to comment
Share on other sites

Ok so with this code the include is done inside the javascript, the spoiler (include.php) becomes visible when the user clicks on the text Find out the spoiler.

[code]    <DIV align=center>
        <p><a href="javascript:InsertContent('spoiler')" class="link">Find out the spoiler !</a></p>
<div id="spoiler" style="font-size: 24px; display: none;">
  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
    <TR>
      <TD>
<?php include ('include.php');


?>

        </TD>
    </TR>
  </TBODY>
</TABLE>

<script type="text/javascript" language="JavaScript"><!--
function InsertContent(d) {
document.getElementById(d).style.display = "";
}
//--></script>
  </div>

[/code]
Link to comment
Share on other sites

[quote author=jesirose link=topic=124341.msg515522#msg515522 date=1170009547]
"Ok so with this code the include is done inside the javascript"
No, it's not.
[/quote]
well not technically but when you see the code it is ;) anyway it was merely for you to see what I want to do with this code.
Link to comment
Share on other sites

[quote author=jesirose link=topic=124341.msg515597#msg515597 date=1170014056]
If I were you I'd look into the Mootools js framework (mootools.net) - it makes js effects simple.
Without a link to the live site, I can't help you any further.
[/quote]
Hello I have a link to a live site now.

Example of what I want is here:
http://www.delux-pass.com/test.php

text which toggles the javascript:
"CLICK HERE TO SEE THE ANSWER"
Link to comment
Share on other sites

[quote author=jesirose link=topic=124341.msg515666#msg515666 date=1170017900]
And what's the problem? When I click it, text shows up.
[/quote]
wait a minute with this example I see the problem finally.. in the include php there was a str_[b]i[/b]replace which their server can't handle but it didn't gave me an error though. except for that the page only loaded untill the javascript.

anyway I found out what was wrong by this example, It does seem to work though then, but actually it shouldn't be working at all ?
as I understand from above.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.