...

View Full Version : Resolved Pass value of an input to a forms "action" on submit...



MoreBloodWine
01-07-2012, 04:08 AM
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>
';

xelawho
01-07-2012, 05:55 AM
this works in FF...



<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>

MoreBloodWine
01-07-2012, 06:13 AM
this works in FF...



<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.

Logic Ali
01-07-2012, 06:44 AM
<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum