passing vars

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry A. Haimann

    passing vars

    I want to pass a variable from one page(in javascript) to a second page(in
    php,) what is the syntax in both lanuages to do such?

    Thx in advance, Terry
  • Fred Serry

    #2
    Re: passing vars


    "Terry A. Haimann" <terry@yngstr.o ldboy.com> schreef in bericht
    news:pan.2003.0 9.10.22.45.35.1 11659@yngstr.ol dboy.com...[color=blue]
    > I want to pass a variable from one page(in javascript) to a second[/color]
    page(in[color=blue]
    > php,) what is the syntax in both lanuages to do such?
    >
    > Thx in advance, Terry[/color]

    Hi,

    Put the values in hidden inputs on a form and post it to your php page.
    The posted inputs will be available in php as variables.

    <form action="myFile. php" method="post" name="myForm">
    <input type="hidden" name="myVar" value="">
    </form>
    <script type="text/javascript">
    document.forms["myForm"].elements["myVar"].value="Hello world"
    document.forms["myForm"].submit()
    <script>

    ------------------------

    myFile.php:

    echo "Received value: ".$myVar ;


    hth Fred


    Comment

    • Terry A. Haimann

      #3
      Re: passing vars

      Thx, I had scoured the book stores, but hadn't figured it out. Last night
      I was back at b&n("to feed my mocha habit") when I came across Query
      Strings. I added the code and they seem to work.

      On Thu, 11 Sep 2003 09:03:47 +0200, Fred Serry wrote:
      [color=blue]
      >
      > "Terry A. Haimann" <terry@yngstr.o ldboy.com> schreef in bericht
      > news:pan.2003.0 9.10.22.45.35.1 11659@yngstr.ol dboy.com...[color=green]
      >> I want to pass a variable from one page(in javascript) to a second[/color]
      > page(in[color=green]
      >> php,) what is the syntax in both lanuages to do such?
      >>
      >> Thx in advance, Terry[/color]
      >
      > Hi,
      >
      > Put the values in hidden inputs on a form and post it to your php page.
      > The posted inputs will be available in php as variables.
      >
      > <form action="myFile. php" method="post" name="myForm">
      > <input type="hidden" name="myVar" value="">
      > </form>
      > <script type="text/javascript">
      > document.forms["myForm"].elements["myVar"].value="Hello world"
      > document.forms["myForm"].submit()
      > <script>
      >
      > ------------------------
      >
      > myFile.php:
      >
      > echo "Received value: ".$myVar ;
      >
      >
      > hth Fred[/color]

      Comment

      Working...