#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Hannover,Germany
    Posts
    3
    Rep Power
    0
    Does anyone know if/how I can use a variable created by a JavaScript "confirm()" field for example within my PHP script directly (without posting it as a query string again to the same page)?

    ------------------
    :: Best regards, Sebastian Rbke
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    61
    Rep Power
    15
    A way I've done it in the past is to send the browser the variables through the URL. Then, when you get into the php, just do $REQUEST_URL or something(look it up on php.net), and parse_str(). You may want to have the javascript page do a setTimeOut() thing and redirect it to the php page.

    If that made sense to you, great.
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    Have a hidden form field in your page, then have your confirm() function change the value of that variable. when the form is submitted, the next PHP page can then use it.

    <script language=javascript>
    function confirm()
    {
    document.form1.myvar.value = 'john';
    }
    </script>
    <form name=form1 method=post action=test.php ONSUBMIT="confirm();">
    <input type=text name=name>
    <input type=hidden name=myvar>
    <input type=submit value=Submit>
    </form>

    Hope that helps...

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    Hannover,Germany
    Posts
    3
    Rep Power
    0
    Thanks for your replies ;-)
    Ive managed to solve the problem using your suggestions, but what I really wanted to do is to influence the further php-code by the confirm() field, without transferring the variable again by a form. I know that its a limitation of the client-server model at the moment.

    Of course, the solution Im now using works very fine ;-) Thanks again.

    [This message has been edited by sebastian.roebke (edited December 27, 2000).]

IMN logo majestic logo threadwatch logo seochat tools logo