passing php variables with javascript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dkirkdrei@yahoo.com

    passing php variables with javascript?

    I am trying to open a small new window using javascript and pass a php
    variable onto the new window and this is really being a pain. I believe
    that this is possible but everything that I have tried so far has not
    worked. The relevant code that I am usiing is below. Everything works
    like it should except the new window contains nothing. Anyone familiar
    with this? Any help would be greatly appreciated.

    <?
    if ($yes_no == "Y"){
    ?><td><a href="javascrip t:newwindow('<? print ($aster);?>')"
    title='<?echo "$aster"?>'>Not es</a></td><?
    } else { ?><td>&nbsp;</td><?
    }
    ?>
    </tr>
    <?
    }
    odbc_close($con nect);
    ?>
    <SCRIPT language="JavaS cript">
    <!--hide
    function newwindow()
    {
    window.open('cu st_parts_notes. php','Notes','w idth=300,height =200,resizable= yes');

    }
    //-->
    </SCRIPT>
    </body>
    </html>

    The referenced page 'cust_parts_not es.php' only contains:

    <?
    echo "$aster";
    ?>

  • Matthew256

    #2
    Re: passing php variables with javascript?


    dkirkd...@yahoo .com wrote:
    I am trying to open a small new window using javascript and pass a php
    variable onto the new window and this is really being a pain. I believe
    that this is possible but everything that I have tried so far has not
    worked. The relevant code that I am usiing is below. Everything works
    like it should except the new window contains nothing. Anyone familiar
    with this? Any help would be greatly appreciated.
    >
    <?
    if ($yes_no == "Y"){
    ?><td><a href="javascrip t:newwindow('<? print ($aster);?>')"
    title='<?echo "$aster"?>'>Not es</a></td><?
    } else { ?><td>&nbsp;</td><?
    }
    ?>
    </tr>
    <?
    }
    odbc_close($con nect);
    ?>
    <SCRIPT language="JavaS cript">
    <!--hide
    function newwindow()
    {
    window.open('cu st_parts_notes. php','Notes','w idth=300,height =200,resizable= yes');
    >
    }
    //-->
    </SCRIPT>
    </body>
    </html>
    >
    The referenced page 'cust_parts_not es.php' only contains:
    >
    <?
    echo "$aster";
    ?>

    window.open('cu st_parts_notes. php?aster=<?pri nt
    ($aster);?>','N otes','width=30 0,height=200,re sizable=yes');

    echo $_GET['aster'];

    Comment

    • dkirkdrei@yahoo.com

      #3
      Re: passing php variables with javascript?


      Matthew256 wrote:
      dkirkd...@yahoo .com wrote:
      I am trying to open a small new window using javascript and pass a php
      variable onto the new window and this is really being a pain. I believe
      that this is possible but everything that I have tried so far has not
      worked. The relevant code that I am usiing is below. Everything works
      like it should except the new window contains nothing. Anyone familiar
      with this? Any help would be greatly appreciated.

      <?
      if ($yes_no == "Y"){
      ?><td><a href="javascrip t:newwindow('<? print ($aster);?>')"
      title='<?echo "$aster"?>'>Not es</a></td><?
      } else { ?><td>&nbsp;</td><?
      }
      ?>
      </tr>
      <?
      }
      odbc_close($con nect);
      ?>
      <SCRIPT language="JavaS cript">
      <!--hide
      function newwindow()
      {
      window.open('cu st_parts_notes. php','Notes','w idth=300,height =200,resizable= yes');

      }
      //-->
      </SCRIPT>
      </body>
      </html>

      The referenced page 'cust_parts_not es.php' only contains:

      <?
      echo "$aster";
      ?>
      >
      >
      window.open('cu st_parts_notes. php?aster=<?pri nt
      ($aster);?>','N otes','width=30 0,height=200,re sizable=yes');
      >
      echo $_GET['aster'];
      Thanks, thats getting there. My variable $aster can be many things
      depending on its location in the resulted table. With the code that you
      suggested, it only echo's the last result in the table. I will have to
      do a little tweaking. thanks again.

      Comment

      • william.clarke

        #4
        Re: passing php variables with javascript?

        You could also stored $aster in a session variable and retrieve it with
        the page in the new window. See the php doco for a few good examples of
        session usage: http://au3.php.net/manual/en/function.session-start.php

        Comment

        Working...