Jump to content

Recommended Posts

I have an inframe PHP coded form within a HTML page. I like to have a pop-up window for more info.

I can not figure out how.

 

I think I have to exit the PHP secession and start a HTML secession and put in some javascript??

 

Can someone give some help on what direction to go and how?

 

Thanks a Lot

Russ

php is parsed on the server and the results are sent to the client (your browser).  Javascript is parsed on the client.  All of the php script will be executed and results sent before a single piece of javascript is executed, no matter what kind of order you put it in.  If you want some kind of "live" interaction, where you start off with php and have more php executed based off of js, look into ajax.

it doesn't really matter how you write your php really as long as the javascript in your browser source is correct.

 

if you would do something like

<scr<?php echo("ipt>aler");?>t('alert something')</script>

and you would check your html source it would show

<script>alert('something')</script>

 

and it would still work

 

then again maybe you mean you want to have values from the popup to the parent page which is also possible

well, you can use php to dynamically create text, and js/html is text to php so if you want the text to contain js code to be generated for a popup on one condition but not another, then to that extent, yes, you can use php to do that. Example:

 

$x = 5;
if ($x > 0) {
   // echo js for popup box here
} else {
  // don't echo out js
}

 

That code will send the js popup code to the browser, but the point is, the condition will be parsed on the server, and the results will be sent to the browser. 

 

<?php
   echo "something here<br />";
?>

<script language='javascript'>
   document.write("blahblahblah"); 
</script>

<?php 
   echo "something else here <br />";
?>

 

php will parse that and send the following to the browser:

 

something here<br />
<script language='javascript'>
   document.write("blahblahblah<br />"); 
</script>
something else here <br />

 

So your browser is going to render that text in order, looking like this:

 

something here

blahblahblah

something else here

 

The point I'm trying to make is that even if the js was a popup, it will still be rendered in that order, and the 2nd php echoed string will still be there.  If he has some php script running and suddenly wants a js popup box to confirm something, he can do that, but he can't for instance have the php script continue to run if he clicks yes, stop if he clicks no, because all of the php is already parsed on the server and sent to the browser. 

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.