[ic] Checkboxes, userdb, account.html, checkout.html, etc.

ICdev interchange.mail at virgin.net
Wed Oct 15 00:37:13 EDT 2003


Hey all,

I have modified account.html and checkout.html so that the billing fields are 
only displayed if a 'Billing address same as shipping' checkbox is unticked. 
I have also modified profiles.order so that the billing details are only 
checked if the checkbox is unticked. Here is what I am trying to achieve:

1. When someone logs in, I want to make sure that the fields are displayed 
correctly according to whether or not they have billing details in userdb.

Thanks to the archives, I fixed the bugs in account.html with values not being 
checked, values disappearing on a failed check, and remaining on the same 
page after submittal, by changing mv_order_profile to mv_form_profile, 
putting [update values] at the top of the page, and adding 
'&fail=@@MV_PAGE@@' and '&success=customerservice' to profiles.order, 
respectively.

2. Now that I've fixed the aforementioned checking problem in account.html, I 
get an 'errors in last submission' if I only fill in the shipping fields and 
tick the checkbox, despite the fact that IC shouldn't be checking the billing 
fields if my 'bill_eq_ship' variable is set to 'yes' (see code below). This 
is what happens with [update values] in the page; without it, I cannot tick 
the 'bill_eq_ship' checkbox at all, I just get the same thing, but with the 
billing fields displayed as well.

Actually, I'm getting some very weird behavior with the checking on 
account.html. If I log out after the failed shipping-only submission 
mentioned above, then log in again using an account with billing values in 
userdb, an error will be highlighted, even though the field has been filled 
in. The form passes the check when submitted, and when going back a second 
time, everything is OK. I have also run into a couple of occasions where, for 
example, when leaving out the billing first name, instead of that getting 
highlighted, the phone field does instead. Then after re-submitting the form, 
b_fname is highlighted, as expected.

Here is the code from account.html / checkout.html:

- - -

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

	(shipping fields)

<input type=checkbox name=bill_eq_ship value=yes [checked bill_eq_ship yes] 
onClick="this.form.submit()">
    [comment]Value is reset at end of this page[/comment]

[if value bill_eq_ship =~ /no/i]

	(display billing fields)

[/if]

[value name=bill_eq_ship set='no' hide=1]

- - -

And the code from the account.html section of profiles.order:


__NAME__                            account_change
&fail=@@MV_PAGE@@
&success=customerservice
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]

__END__

- - -

Of course, if you put something like the following in the page, you get a 
catch-22. Without it, the fields won't be displayed correctly when logging 
in, but with it, you cannot untick the checkbox.

[if !value b_fname]
  [value name=bill_eq_ship set='yes' hide=1]
[/if]

I thought about something that might work for account.html, but not 
checkout.html, supposing there is a way to implement it:

"If the previous page was a page other than account.html, and there are no b_* 
values, set bill_eq_ship to 'yes'."

Does anyone have any ideas? I really need someone's help to get the better of 
this.

Thank you!

Using IC 4.8.7.





More information about the interchange-users mailing list