www.webdeveloper.com
Results 1 to 5 of 5

Thread: Turning javascript variables ( Jquery?) to php

  1. #1
    Join Date
    Apr 2013
    Posts
    3

    Turning javascript variables ( Jquery?) to php

    Hi i have a variable that I would like to somehow become a php variable without using ajax

    The answer on stackoverflow mid page SEEMS right, and everything in my environment mimics his example but i still cannot get it to work

  2. #2
    Join Date
    Apr 2013
    Posts
    56
    Hello,

    I do not think this is possible. You cannot mix server side and client side code. You can however as have others suggested on stackoverflow assign variable to form element and pass it to your PHP script as form post action.
    You can post your code and errors if you want to get additional help.

  3. #3
    Join Date
    Apr 2013
    Posts
    3

    The code

    Here is my html form with javascript
    jquery_phptest.php >>>>

    I keep getting returned an Emptry string. Any ideas?



    HTML Code:
            <script type="text/javascript" src="jquery.js"/>
    
        <script type="text/javascript">
            
        $(document).ready(function(){
          var test = "hello";
          $('#someinput').value(test);
           document.getElementByID("someinput").value = test;
       });
        </script>
        
        
        <form action="some.php" id="someinput" method="post">
    <input type="hidden" id="someinput2" name="someinput"/>
    <input type="submit" value="send"/>
    </form>
        
    The php file >>>
    some.php

    PHP Code:
    <?php
    var_dump
    ($_GET['someinput']);

    ?>

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    <input type="hidden" id="someinput2" name="someinput"/> is empty, aka has no value=...

  5. #5
    Join Date
    Apr 2013
    Posts
    3
    How would you do it??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles