How to Pass PHP variables to JS?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Don

    How to Pass PHP variables to JS?

    How do I pass PHP variables to JavaScript in the returned browser page?

    Thanks,
    Don
  • David Zawislak

    #2
    Re: How to Pass PHP variables to JS?

    Don wrote:
    [color=blue]
    > How do I pass PHP variables to JavaScript in the returned browser page?
    >
    > Thanks,
    > Don[/color]
    Well, you could do this if you have a variable $_POST['name']:
    ....
    some javascript
    .....

    echo 'var name = ' . $_POST['name'];

    ....
    Just like HTML, but you write valid javascript.

    Comment

    • Don

      #3
      Re: How to Pass PHP variables to JS?

      On Mon, 08 Nov 2004 14:04:37 -0600, David Zawislak <davez0411@exci te.com> wrote:
      [color=blue]
      >Don wrote:
      >[color=green]
      >> How do I pass PHP variables to JavaScript in the returned browser page?
      >>
      >> Thanks,
      >> Don[/color]
      >Well, you could do this if you have a variable $_POST['name']:
      >...
      >some javascript
      >....
      >
      >echo 'var name = ' . $_POST['name'];
      >
      >...
      >Just like HTML, but you write valid javascript.[/color]

      Thanks David. That worked just fine.

      Regards,
      Don


      ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
      http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
      ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

      Comment

      • Jeremy Smith

        #4
        Re: How to Pass PHP variables to JS?

        Don wrote:[color=blue]
        > How do I pass PHP variables to JavaScript in the returned browser page?
        >
        > Thanks,
        > Don[/color]

        <?
        $hello = "hello";
        ?>

        <script language="javas cript">
        alert("<?=$hell o;?>");
        </script>

        Comment

        • Warren Oates

          #5
          Re: How to Pass PHP variables to JS?

          In article <1100189674./W3ZIuK13gf7EpV3 ROowxg@teranews >,
          Jeremy Smith <di99smje@chl.c halmers.se> wrote:

          :<script language="javas cript">
          :alert("<?=$hel lo;?>");
          :</script>

          Or (something useful):

          <?php
          $referred_to = 'http://127.0.0.1/~you/old_browser.php ';
          ?>

          <script language="Javas cript" type="text/javascript">
          if (!document.getE lementById) {
          top.location.re place("<?php echo $referred_to; ?>");
          }
          </script>
          --
          Looks like more of Texas to me.
          .... Arizona, where the nights are warm and the roads are straight.

          Comment

          • Don

            #6
            Re: How to Pass PHP variables to JS?

            On Thu, 11 Nov 2004 17:14:31 +0100, Jeremy Smith <di99smje@chl.c halmers.se> wrote:
            [color=blue]
            >Don wrote:[color=green]
            >> How do I pass PHP variables to JavaScript in the returned browser page?
            >>
            >> Thanks,
            >> Don[/color]
            >
            ><?
            >$hello = "hello";
            >?>
            >
            ><script language="javas cript">
            >alert("<?=$hel lo;?>");
            ></script>[/color]
            Thanks Jeremy.
            Don


            ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
            http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
            ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

            Comment

            • Don

              #7
              Re: How to Pass PHP variables to JS?

              On Thu, 11 Nov 2004 11:45:39 -0500, Warren Oates <Warren.Oates@G mail.com> wrote:
              [color=blue]
              >In article <1100189674./W3ZIuK13gf7EpV3 ROowxg@teranews >,
              > Jeremy Smith <di99smje@chl.c halmers.se> wrote:
              >
              >:<script language="javas cript">
              >:alert("<?=$he llo;?>");
              >:</script>
              >
              >Or (something useful):
              >
              ><?php
              >$referred_to = 'http://127.0.0.1/~you/old_browser.php ';
              >?>
              >
              ><script language="Javas cript" type="text/javascript">
              >if (!document.getE lementById) {
              >top.location.r eplace("<?php echo $referred_to; ?>");
              >}
              ></script>[/color]
              Thanks Warren.
              Don


              ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
              http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
              ---= East/West-Coast Server Farms - Total Privacy via Encryption =---

              Comment

              Working...