Jump to content

javascript passing through to php


gudfry

Recommended Posts

hi maybe i was in the the wrong area, Sory for convenience,

 

I was looking for a code to test, and i found this code. when I reun it to my browser it has no action happen, i dont know if i was correct. the code is not function well. any idea with this to make the code work?? pls help me.

           

            <?php

msgbox("Are you sure?", "confirm");

$result="";

if ($result == "ok")

    {

    // Perform some "ok" action here...

    }

else

    {

    // Perform some "cancel" action here...

    }

 

  function msgbox($msg, $type)

      {

      if ($type == "alert")

          {

        // Simple alert window

  ?> <script language="JavaScript"> alert("<?php echo $msg; ?>"); </script>

      <?php

        }

      elseif ($type == "confirm")

        {

     

        ?>

          <script language="JavaScript">

          if (confirm("<? echo $msg; ?>"))

                {

                <?php $result == "ok"; ?>

                }

          else

                {

                <?php $result == "cancel"; ?>

                }

          </script>

        <?php

        }

    }

?>

 

 

thanks in advance

Link to comment
Share on other sites

PHP is server side.  Javascript is client side.  PHP will be processed before it's ever sent to the user.  Javascript is processed when the user gets the page.

 

Also, based on some of your syntax, you don't understand PHP basics.  Maybe google a little?

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.