[ic] account.html conditional error checking - SOLVED

ICdev interchange.mail at virgin.net
Fri Oct 24 00:37:08 EDT 2003


> I don't know if my last post about this was unclear (titled 'Checkboxes,
> userdb, account.html, checkout.html, etc.'), but it didn't get any replies,
> so I'll try again and keep it simpler this time.
>
> In checkout.html and account.html, I am conditionally error checking the
> billing fields, depending on the value of a checkbox. This is working fine
> in the checkout page, but not account.html.
>
> The problem is that even when the checkbox 'bill_eq_ship' variable is set,
> Interchange still tries to check for billing values.
>
> Would someone please check the code below, and tell me what's up.
>
>
> Bits from account.html:
>
> - - -
>
> [update values]
>
> [comment]If never been set before, assign default[/comment]
> [if !value bill_eq_ship]
>   [if !value b_fname]
>     [value name=bill_eq_ship set='yes' hide=1]
>   [else]
>     [value name=bill_eq_ship set='no' hide=1]
>   [/else]
>   [/if]
> [/if]
>
> [if value bill_eq_ship =~ /yes/i]
> 	[value name=b_fname set='']
> 	[value name=b_lname set='']
> 	[value name=b_company set='']
> 	[value name=b_address1 set='']
> 	[value name=b_address2 set='']
> 	[value name=b_city set='']
> 	[value name=b_state set='']
> 	[value name=b_zip set='']
> 	[value name=b_country set='']
> [/if]
>
> <FORM ACTION="[process secure=1]" METHOD="POST">
> <INPUT TYPE=hidden NAME=mv_session_id VALUE="[data session id]">
> <INPUT TYPE=hidden NAME=mv_form_profile VALUE=account_change>
> <INPUT TYPE=hidden NAME=mv_todo     VALUE=return>
> <INPUT TYPE=hidden NAME=mv_nextpage VALUE=@@MV_PAGE@@>
> <INPUT TYPE=hidden NAME=mv_check    VALUE="Save_database">
>
> [set Save_database]
> [userdb save]
> [/set]
>
> <input type=checkbox name=bill_eq_ship value=yes [checked bill_eq_ship yes]
> onClick="this.form.submit()">
>
> <INPUT TYPE=SUBMIT VALUE="Save Details">
>
> [if items]
>   [set Save and Checkout]
>     mv_nextpage=ord/checkout
>   [/set]
>
>   <INPUT TYPE=SUBMIT VALUE="Save and Checkout" NAME=mv_click>
>   <br><br>
>   <A HREF="[area ord/checkout]">No change, go to checkout</A>
> [/if]
>
> </FORM>
>
> [value name=bill_eq_ship set='no' hide=1]
>
> - - -
>
>
>In profiles.order:
>
> __NAME__                            account_change
> fname=required
> lname=required
> address1=required
> city=required
> country=required
> [if value country =~ /^(US|CA)$/i]
> 	state=state_province
> 	zip=postcode
> [else]
> state=required
> zip=required
> [/else]
> [/if]
> &or phone_night=phone, phone_day=phone Must have day or evening phone
> number
>
> email=required
> &fatal = yes
> email=email
>
> [if value bill_eq_ship =~ /no/i]
> b_fname=required
> b_lname=required
> b_address1=required
> b_city=required
> b_country=required
>   [if value b_country =~ /^(US|CA)$/i]
> 	b_state=state_province
> 	b_zip=postcode
>   [else]
> 	b_state=required
> 	b_zip=required
>   [/else]
>   [/if]
> [/if]
>
> &fail=@@MV_PAGE@@
> &success=customerservice
>
> __END__
>
>
> Thank you.



OK, I've got something working at last, and I'll post this in case anyone else 
has the same problem, which is more than likely.

Although I haven't had time to dig through the source, it appears that 
mv_form_profile was doing the validation *before* the bill_eq_ship form 
variable was passed to profiles.order. That is, the checkbox value wasn't 
being used in the profile at all; the value of bill_eq_ship was always 'no'.

What I did was use 'mv_order_profile' instead, replaced this:

<INPUT TYPE=SUBMIT VALUE="Save Details">

with this:

[button text="Save Details" form="account"]
mv_todo=submit
[/button]

at the bottom of the page, and also put '&final=no' in the profile.



More information about the interchange-users mailing list