Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Pass value of an input to a forms "action" on submit...

    What needs to be done to have the below input (red) passed to the forms action (blue) when the submit button is pressed. Obviously this should be the user input value and not the default 0.00 one.

    Ty.

    echo '
    <center>
    <form method="post" action="https://www.paymate.com/PayMate/ExpressPayment?mid=MoreBloodWine&popup=false&ref=EoJ Market Place Donation&currency=USD&amt=1.23&amt_editable=N&return=http://www.eojmarket.com">
    Donation Amount: $<input style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 50px;" name="amount" type="text" maxlength="6" value="0.00">
    <br />
    <input type="image" style="padding-top: 10px; padding-bottom: 10px; border: none;" src="http://www.eojmarket.com/NonForumStuff/images/paymate-donate-button.png" value="Submit" alt="Pay with Paymate Express !"/>
    </form>
    </center>
    ';
    Last edited by MoreBloodWine; 01-07-2012 at 07:14 AM.

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,983
    Thanks
    56
    Thanked 557 Times in 554 Posts
    this works in FF...

    Code:
    <body>
    <center>
    <form name="myform">
    Donation Amount: $<input type="text" name="amount" maxlength="6" value="0.00"/>
    </form>
    <input type="image"  onclick="post_to_url()" style="padding-top: 10px; padding-bottom: 10px; border: none;" src="http://www.eojmarket.com/NonForumStuff/images/paymate-donate-button.png" alt="Pay with Paymate Express !"/>
    </center>
    <script type="text/javascript">
    
    	
    
    function post_to_url() {
    var AMT=document.myform.amount.value;
        var form = document.createElement("form");
        form.setAttribute("method", "post");
        form.setAttribute("action", "https://www.paymate.com/PayMate/ExpressPayment?mid=MoreBloodWine&popup=false&ref=EoJ Market Place Donation&currency=USD&amt="+AMT+"&amt_editable=N&return=http://www.eojmarket.com");
        document.body.appendChild(form);
        form.submit();
    }
    
    </script>
    </body>

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    204
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by xelawho View Post
    this works in FF...

    Code:
    <body>
    <center>
    <form name="myform">
    Donation Amount: $<input type="text" name="amount" maxlength="6" value="0.00"/>
    </form>
    <input type="image"  onclick="post_to_url()" style="padding-top: 10px; padding-bottom: 10px; border: none;" src="http://www.eojmarket.com/NonForumStuff/images/paymate-donate-button.png" alt="Pay with Paymate Express !"/>
    </center>
    <script type="text/javascript">
    
    	
    
    function post_to_url() {
    var AMT=document.myform.amount.value;
        var form = document.createElement("form");
        form.setAttribute("method", "post");
        form.setAttribute("action", "https://www.paymate.com/PayMate/ExpressPayment?mid=MoreBloodWine&popup=false&ref=EoJ Market Place Donation&currency=USD&amt="+AMT+"&amt_editable=N&return=http://www.eojmarket.com");
        document.body.appendChild(form);
        form.submit();
    }
    
    </script>
    </body>
    It would have to work in all browsers to be useful to my clients... this includes IE8 etc.

  • #4
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Code:
    <html>
    <head>
    </head>
    <title>TEST</title>
    <body>
    
    <form method="post" id="myForm" action="https://www.paymate.com/PayMate/ExpressPayment?mid=MoreBloodWine&popup=false&ref=EoJ Market Place Donation&currency=USD&amt=1.23&amt_editable=N&return=http://www.eojmarket.com">
    Donation Amount: $<input style="vertical-align: middle; color: #FFFFFF; background-color: transparent; border: 1px solid; border-color: #9E853D; padding: 0px 0px 0px 1px; font-size: 10px; width: 50px;" name="amount" type="text" maxlength="6" value="0.00">
    <br />
    <input type="image" style="padding-top: 10px; padding-bottom: 10px; border: none;" src="http://www.eojmarket.com/NonForumStuff/images/paymate-donate-button.png" value="Submit" alt="Pay with Paymate Express !"/>
    </form>
    <script type="text/javascript">
    
    document.getElementById( 'myForm' ).onsubmit = function()
    {
      var amt, ok = false;
        
      if( !isNaN( amt = parseFloat( this.amount.value ) ) && amt > 0 )
      {
        this.action = this.action.replace( /(\&amt=)\d+\.\d{1,2}/, "$1"+amt );
        ok = true;
      }
      
      return ok;
    }
    
    </script>
    </body>
    </html>


  •  

    Posting Permissions

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