how can I pass a php varialbe with an onClick= event handler?

    I'm not too familiar with Javascript - if you used onClick to redirect to another page with a $_GET variable, would that solve your problem? You might need to look into a more in-depth solution, maybe an AJAX function of some kind?

      fearfx wrote:

      how can I pass a php varialbe with an onClick= event handler?

      I do not use Javacscript.
      ... use PHP as much as possible.

      Then if you really want expert answers on JAVASCRIPT
      there are plenty of websites with
      - AJAX javascripts
      - Javascripts
      - Java

      Just because you go to Java website for talk java with those EXPERTS
      does not mean you can not be here
      Talking PHP.
      🙂

      I mean, if I want to talk religion or philosophy,
      there are other websites I go to discuss.
      I would not 1st thing ask here, at http://phpbuilder.com for such questions.

      It would not be smart, would it?
      Not if I want to give myself best chances of getting best answers/solutions.

      Regards

      🙂

        If you just want to use a php var in javascript without going to another page you can build a javascript function with php

        <html>
        <head>
          <title></title>
        <?php
          $php_var = "reddrum is ugly";
          print"<script language='javascript' type='text/javascript'>";
             print"function php_to_js(){";
                print"var js_var = '$php_var';";
                print"alert(js_var);";
             print"}";
          print"</script>";
        ?>
        </head>
        
        <body>
              <input type="button" onclick="javascript:php_to_js()" value="Click Me" />
        </body>
        
        </html>
        

        Also I have a script from Webmonkey to parse get with javascript, I have never tryed it though. Using the two methods could pass a php var with javascript to anouther page.

        <script language="JavaScript">
        <!--
        
        /*
        Webmonkey GET Parsing Module
        Language: JavaScript 1.0
        
        The parsing of GET queries is fundamental
        to the basic functionality of HTTP/1.0.
        This module parses GET with JavaScript 1.0.
        
        Source: Webmonkey Code Library
        (http://www.hotwired.com/webmonkey/javascript/code_library/)
        
        Author: Patrick Corcoran
        Author Email: patrick@taylor.org
        */
        
        function createRequestObject() {
        
          FORM_DATA = new Object();
            // The Object ("Array") where our data will be stored.
        
          separator = ',';
            // The token used to separate data from multi-select inputs
        
          query = '' + this.location;
            // Get the current URL so we can parse out the data.
            // Adding a null-string '' forces an implicit type cast
            // from property to string, for NS2 compatibility.
        
          query = query.substring((query.indexOf('?')) + 1);
            // Keep everything after the question mark '?'.
        
          if (query.length < 1) { return false; }  // Perhaps we got some bad data?
        
          keypairs = new Object();
          numKP = 1;
            // Local vars used to store and keep track of name/value pairs
            // as we parse them back into a usable form.
        
          while (query.indexOf('&') > -1) {
            keypairs[numKP] = query.substring(0,query.indexOf('&'));
            query = query.substring((query.indexOf('&')) + 1);
            numKP++;
              // Split the query string at each '&', storing the left-hand side
              // of the split in a new keypairs[] holder, and chopping the query
              // so that it gets the value of the right-hand string.
          }
        
          keypairs[numKP] = query;
            // Store what's left in the query string as the final keypairs[] data.
        
          for (i in keypairs) {
            keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
              // Left of '=' is name.
            keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
              // Right of '=' is value.
            while (keyValue.indexOf('+') > -1) {
              keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
                // Replace each '+' in data string with a space.
            }
        
        keyValue = unescape(keyValue);
          // Unescape non-alphanumerics
        
        if (FORM_DATA[keyName]) {
          FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
            // Object already exists, it is probably a multi-select input,
            // and we need to generate a separator-delimited string
            // by appending to what we already have stored.
        } else {
          FORM_DATA[keyName] = keyValue;
            // Normal case: name gets value.
        }
          }
        
          return FORM_DATA;
        }
        
        FORM_DATA = createRequestObject();
          // This is the array/object containing the GET data.
          // Retrieve information with 'FORM_DATA [ key ] = value'.
        
        
        // -->
        
        </script>
        
          Write a Reply...