Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing a form field value programatically before submit 2

Status
Not open for further replies.

CMcC

Programmer
Feb 5, 2002
196
US
Hello.
I have a form where the user will enter an amount, where the field that they are entering it in is a variable that will be passed to another URL.
It is a number field (Currency). I would like to be able to add (.50 cent) onto the value of this field before the form is submitted. The field in question is
"pg_total_amount".

This does not change what the user entered. Instead I get an error

"Must be numeric value and greater than zero : pg_total_amount. "





This is what I have so far:

Code:
<form method='post' action= '[URL unfurl="true"]https://swp.paymentsgateway.net/default.aspx'>[/URL]  <div align="center" onfocus="MM_validateForm('pg_billto_postal_name_company','','R');return document.MM_returnValue">
    <table width="574" border="0" align="center" cellspacing="0" bordercolor="#996600">
            
     
      <tr>
        <td align="right" width="260"><p align="right"><b>Dealer Name<font color="#ff0000" face="Arial, Helvetica"> *</font></b> </p></td>
        <td width="310"><font face="Arial, Helvetica">
              
          <input name="pg_billto_postal_name_company" id="pg_billto_postal_name_company" 
      size="35" />
        </font></td>
      </tr>
      <tr>
        <td align="right" width="260"><p><span class="style1"><b>Dealer Number</b></span><b><font color="#ff0000" face="Arial, Helvetica">*</font></b></p></td>
        <td width="310"><font face="Arial, Helvetica">
          <input name="pg_consumerorderid" id="pg_consumerorderid" 
      size="35" />
        </font></td>
      </tr>
      <tr>
        <td align="right" width="260"><p><span class="style1"><b>Payment Amoun</b></span><b>t  <font color="#ff0000" face="Arial, Helvetica"> *<span class="style3">(No comma) </span></font></b></p>
          <p><font face="Arial, Helvetica"><br />
            </font></p></td>
        <td width="310"><font face="Arial, Helvetica">
          [red]<input name="pg_total_amount" id ="pg_total_amount" 
      size="35" />[/red]
        </font></td>
      </tr>
      <tr>
        <td align="right" width="260"><p><span class="style1"><b>Batch Number</b></span><font face="Arial, Helvetica"><b><font 
      color="#ff0000" 
     >*</font></b></font></p></td>
        <td width="310"><font face="Arial, Helvetica">
              
          <input name="pg_merchant_data_3" id="pg_merchant_data_3" 
      size="35" />
        </font></td>
      </tr>
    </table>
   </div>
[red]
/*  THIS IS WHERE I TRY TO ALTER THE AMOUNT
<%
dim total_amount
total_amount = pg_total_amount + .50 
%>
[/red]



<table cellSpacing='0' cellPadding='0' border='0'><tr><td align='right' width='300'></td><td width='200' align='left' onfocus="MM_validateForm('pg_billto_postal_name_company','','R','pg_consumerorderid','','R','pg_total_amount','','R','pg_merchant_data_3','','R');return document.MM_returnValue">
<input type='hidden' name='pg_api_login_id' value='1PeYtqSMv5'/>
[red]

*/ THIS IS WHERE I WAS TRYING TO SEND OVER SUBMIT

<input type='hidden' name='pg_total_amount' value='<%=total_amount%>'/>
[/red]

<input type='hidden' name='pg_merchant_data_1' value='N/A'/>
<input type='hidden' name='pg_merchant_data_2' value='N/A'/>
<input type='hidden' name='pg_walletid' value='Dealer Work'/>
</td></tr><tr><td align='right' width='300'></td><td align='left' width='200'><input type='hidden' type='text' name='pg_return_url' value='[URL unfurl="true"]http://www.seminoletax.org/dev/dealer/dealerACHreturn.asp'/></td></tr><tr><td[/URL] align='right' width='300'></td><td align='left' width='200'><br></td></tr><tr><td align='right' width='300'></td><td align='left' width='200'><INPUT TYPE=SUBMIT value='Pay by eCheck Now'><br></td></tr></table></form>
So I guess my question is what is the appropriate syntax to change a form value before it is submitted?

THANKS!
 
you cannot alter the amount the way you are doing it.

I would suggest you send the form to a processing page.

IE.

form page >> processing page >> thank you page

this is the simplest way to explain.

you can do it on the fly but I do not know that syntax.

Darryn Cooke
| The New Orange County Graphic designer and Marketing and Advertising Consultant
| Marketing and Advertising blog
 
It looks like you're trying to use VBScript code on the page as clientside code. The only technology that will work cross-browser on the clientside is Javascript, which will not be enabled on maybe 10% of your clients, and is easily edited by the user.

Doing any financial/cash calculations clientside is inadvisable as it is very easy for the user to manipulate. As Darryn says, pass the data back to a handling page, do all your data validation, add your 50 cents and continue to your results page.

As a general rule any clientside code is vulnerable, and should only be used to enhance user experience, and not to provide basic functionality.

If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Thanks guys. I will create a processing page and then send onto the 3rd party vendor.
Cmcc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top