I can't for the life of me figure out what I'm missing here. I'm including some source code and explanation, so this will be a lengthy question.
Skip to: ** THE PROBLEM ** to save time.
I'd like to use a Reset button on a form, but using <input type=image> so that I don't have to use an ugly grey form button. My Submit image button works great. In fact, the Reset button works too, but it doesn't reset anything, it acts just like the Submit button. So I added code to detect a click on the reset button specifically.
My form images are defined on the input form HTML page as:
<INPUT TYPE=IMAGE NAME="reset" SRC=""/assets/siteimages/reset.gif"" ALT="Reset" BORDER=0>
<INPUT TYPE=IMAGE NAME="step" SRC=""/assets/siteimages/step-billinginformation.gif"" ALT="Billing" BORDER=0>
Clicking on the reset form image button results in defined x,y image pixel coordinate values being defined and saved in
<@ARG reset.x> and <@ARG reset.y>
I figure I can just check for <@ARG reset.x>, and see if it has a defined length. If it does, then the rest button has been clicked, and I should use an HTTP Redirect to reload the form input page.
** THE PROBLEM **
When I click the reset button, my code does detect this, but the HTTP Redirect does not occur. Meanwhile, subsequent statements commanding an HTTP Redirect (located in either the same window or subsequent actions) function as expected. The state containing the first function call comanding an HTTP Redirect is a cut and paste copy of the second one seen below, as they should both do the same thing, but the first one should trigger sooner if the Reset button was clicked instead of the Submiot button.
This is code borrowed from the T2K Storefront demo, and modified by me.
user$resetx
is used only for visual display to the HTML output so I can do my own checking manually.
#### Results HTML ####
<@EXCLUDE>
<@PURGE user$resetx>
<@ASSIGN user$resetx Value="<@LENGTH STR='<@ARG reset.x>'>">
</@EXCLUDE>
<@IF "<@LENGTH STR='<@ARG reset.x>'>">
<@ASSIGN user$resetx Value="h2">
<@CALLMETHOD application$Common "HTTPRedirect('<@VAR application$CGI><@VAR application$RootPath>Order/Shipping.taf?_function=input&<@USERREFERENCEARGUMENT>')">
</@IF>
<@EXCLUDE>
<@COMMENT>
<@IF "LEN(<@ARG reset.x>)" TRUE="<@ASSIGN user$resetx Value='<@VAR user$resetx> - LEN(<@ARG reset.x>)'>" FALSE="">
<@IF "<@CALC EXPR=LEN(<@ARG reset.x>)> > 0" TRUE="<@ASSIGN user$resetx Value='<@VAR user$resetx> - LEN(<@ARG reset.x>)'>" FALSE="">
<@ASSIGN user$resetx Value=<@LENGTH STR="<@ARG reset.x>">>
</@COMMENT>
<@! "Track all entered or changed values for user so they dont have to enter them again" >
<@ASSIGN user$ArgShipToName "<@ARG ShipToName>">
<@ASSIGN user$ArgShipToCompany "<@ARG ShipToCompany>">
<@ASSIGN user$ArgShipToAddressLine1 "<@ARG ShipToAddressLine1>">
<@ASSIGN user$ArgShipToAddressLine2 "<@ARG ShipToAddressLine2>">
<@ASSIGN user$ArgShipToAddressLine3 "<@ARG ShipToAddressLine3>">
<@ASSIGN user$ArgShipToCity "<@ARG ShipToCity>">
<@ASSIGN user$ArgShipToState "<@ARG ShipToState>">
<@ASSIGN user$ArgShipToZip "<@ARG ShipToZip>">
<@ASSIGN user$ArgShipToCountry "<@ARG ShipToCountry>">
<@ASSIGN user$ArgShipToPhone "<@ARG ShipToPhone>">
<@ASSIGN user$ShipToResult "BadField">
<@COMMENT>
SET <@VAR user$ShipToResult> = "BadField" until it passes all the checks below. If it does not pass the checks, redirect
back to the main input form again.
</@COMMENT>
<@IF "!LEN(<@ARG ShipToName>) OR LEN(<@ARG ShipToName>) > 100">
<@ASSIGN user$FieldName "you name">
<@ASSIGN user$FieldLength "100">
<@ELSEIF "!LEN(<@ARG ShipToAddressLine1>) OR LEN(<@ARG ShipToAddressLine1>) > 100">
<@ASSIGN user$FieldName "your address">
<@ASSIGN user$FieldLength "100">
<@ELSEIF "!LEN(<@ARG ShipToCity>) OR LEN(<@ARG ShipToCity>) > 100">
<@ASSIGN user$FieldName "your city">
<@ASSIGN user$FieldLength "100">
<@ELSEIF "!LEN(<@ARG ShipToPhone>) OR LEN(<@ARG ShipToPhone>) > 100">
<@ASSIGN user$FieldName "your shipping address phone number">
<@ASSIGN user$FieldLength "100">
<@ELSEIF "!LEN(<@ARG ShipToCountry>)">
<@ASSIGN user$ShipToResult "NoCountry">
<@ELSEIF "!LEN(<@ARG ShipToState>) AND ('<@ARG ShipToCountry>' = 'US' OR '<@ARG ShipToCountry>' = 'CA')">
<@ASSIGN user$ShipToResult "NoState">
<@ELSEIF "<@LENGTH STR='<@ARG reset.x>'>">
<@COMMENT>
Double checking for the Reset button here, but this also fails to trigger the appropriate redirect below.
</@COMMENT>
<@ASSIGN user$ShipToResult "Reset">
<@ASSIGN user$resetx Value=1>
<@PURGE user$ArgShipToName>
<@ELSE>
<@PURGE user$ShipToResult>
<@PURGE user$FieldName>
<@PURGE user$FieldLength>
</@IF>
</@EXCLUDE>
<@IF "LEN(<@VAR user$ShipToResult>)">
<@! "Return to input form" >
<@CALLMETHOD application$Common "HTTPRedirect('<@VAR application$CGI><@VAR application$RootPath>Order/Shipping.taf?_function=input&<@USERREFERENCEARGUMENT>')">
<@COMMENT>
</@COMMENT>
</@IF>
#### End Results HTML ####
The second (last) HTTP Redirect called here does function properly if the other fields checkout OK. It does not function properly if the reset button was pressed and reset.x has a value, which should also mean that <@LENGTH STR='<@ARG reset.x>'> has a value, which should cause <@ASSIGN user$ShipToResult "Reset">.
Feel free to email me privately. Thanks in advance for any help.
Henning Sittler
www.inscriber.com
