SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing variables to php thru $_post??

    Hi all,

    At the moment I have this function, which passes variables to a php file with $_get
    Code:
    function savePath() {
        //store title 
        pathTitle = 'pathTitle=' + document.getElementById("pathTitle").value;
        //pathLength = getPathLength();
        window.location.href = "save-path2.php?"+pathTitle;
    }
    but I need to use $_post

    Code:
    function savePath() {
        //store title so we can use $_post
        pathTitle = 'pathTitle=' + document.getElementById("pathTitle").value;
        
        data = '<form action="save-path2.php" name="formData" method="post">
        <input type="hidden" name="pathTitle" value="'+pathTitle+'" />
        </form>';
         document.formData.submit();
    }
    How would i automaticly submit the form???

  2. #2
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    found a solution by

    using

    Code:
    function savePath() {
       document.formData.pathTitle.value = document.getElementById("pathTitle").value;
        document.formData.submit();
    }
    and between body tags
    <form action="save-path.php" name="formData" method="post">
    <input type="hidden" name="pathTitle" />
    </form>


Bookmarks

Posting Permissions

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