[ic] Need serious help on interchange account.html page, info disappearing

Andrew Brown interchange-users@icdevgroup.org
Fri Dec 27 15:47:01 2002


Hi all:

I've been looking at this code and have no clue where my problem is. Here is what is happening. Basically the account.html form gets validated after you click the continue button. Lets say for example you leave out a field, (address) its successfully shows the errors but does not save any of the fields that you inputed, if you leave out just one field everything else gets erased. The problem is all the information you successfully entered into the other fields disappears. When their is an error nothing in my form gets saved. I cannot for the life of me figure why when their is an error nothing gets saved. I don't know if its something in the account.html page or something in my profile.order file. I've attached the account.html code it's driving me bonkers. Its like nothing gets saved when their is an error.


<!-- BEGIN CONTENT --><SCRIPT>    // JavaScript Form Validation Demo    // by Paul Colton
  function check_tax(form) {
    // Make sure the email field is not blank
    var foundState = false;
    var ch = form.state.value;
    ch = ch.toUpperCase();
    [loop list="__TAXAREA__"]
    if(ch == "[loop-code]") {
      alert("You will be charged [currency][fly-tax [loop-code]][/currency] sales tax\nsince you are shipping to [loop-code]. Click Recalculate to see the amount in your total.");
      foundState = true;
    }
    [/loop]
    return foundState;
  }
</SCRIPT>

[userdb function=get_billing_names]
[userdb function=get_shipping_names]

<table>
<tr>
<td><b>Please fill out your shipping and billing address.</b><br><br>
When finished filling out the fields click the <br>Continue button
to finish your order.</td>
[comment]
<td width="100"></td>
<td>
 <SCRIPT LANGUAGE="JavaScript">
<!--
function OpenShipping()
 {
  window.open('[area shippingfly]','anew', config='height=500,width=550,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,status=yes');
}
// --></SCRIPT><b>Need help with Shipping?</b> &nbsp;<a href="javascript:OpenShipping()"><font color="#3333CC">Click Here</font></a></td>
[/comment]
</tr>
</table>


[set Save_database]
[userdb save]
[/set]
<FORM ACTION="[process secure=1]" METHOD="POST" name="save">
<INPUT TYPE=hidden NAME=mv_session_id VALUE="[data session id]">
[if type=explicit compare="[error all=1 show_var=1 keep=1]"]
<P>
<b>There were errors in your last submission.</b>
<br>
 <blockquote>
        <FONT color="__CONTRAST__">
                [error all=1 keep=1 show_error=1 show_label=1 joiner="<br>"]
        </font>
        </blockquote>

They are shown in <FONT color="red">this color</FONT> below.</FONT>
<P>
[/if]
[comment] account_change profile in etc/profiles.order [/comment]
<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]

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" dwcopytype="CopyTableCell">
  <tr> 
          <td width="25%" bgcolor="#3366FF" height="31"> 
            <div align="right"><font color="#FFFFFF"><b>Shipping Address</b></font></div>
    </td>
          <td width="30%" bgcolor="#3366FF" height="31">&nbsp;</td>
    </tr>
  <tr> 
    <td width="25%" height="16">&nbsp;</td>
    <td width="30%" height="16">&nbsp;</td>
    </tr>
  <tr> 
    <td width="25%" height="16"> 
      <div align="right"></div>
    </td>
    <td width="30%" height="16">&nbsp;</td>
    </tr>
  <tr> 
    <td width="25%" height="21"> 
      <div align="right">Company:</div>
    </td>
    <td width="30%" height="21"> 
      <input type=text name=company value="[value company]" size="20" maxlength="40">
    </td>
    </tr>
  <tr> 
    <td width="25%" height="16"> 
      <div align="right"><b>[error name=fname std_label="First Name:" required=1]</b></div>
    </td>
    <td width="30%" height="16"> 
      <input type=text name=fname value="[value fname]" size="20" maxlength="20">
    </td>
    </tr>
  <tr> 
    <td width="25%" height="21"> 
      <div align="right"><b> [error name=lname std_label="Last Name:" required=1]</b></div>
    </td>
    <td width="30%" height="21"> 
      <input type=text name=lname value="[value lname]" size="20">
    </td>
    </tr>
  <tr> 
    <td width="25%" height="18"> 
      <div align="right"><b>[error name=address1 std_label=Address: required=1]</b></div>
    </td>
    <td width="30%" height="18"> 
      <input type=text name=address1 value="[value address1]" size="40" maxlength="40">
    </td>
    </tr>
  <tr> 
    <td width="25%" height="19"> 
      <div align="right"></div>
    </td>
    <td width="30%" height="19"> 
      <input type=text name=address2 value="[value address2]" size="40" maxlength="40">
    </td>
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"><b>[error name=city std_label="City:" required=1]</b> </div>
    </td>
    <td width="30%"> 
      <input type=text name=city value="[value city]" size="20" maxlength="20">
    </td>
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"><b>[error name=state std_label="State/Province:" required=1]</b></div>
    </td>
    <td width="30%"> 

 [loop search="
                fi=state.txt
                sf=country
                se=[default country US]
                rf=state,name,country
                tf=sorder,name
                ml=100
              "
              option=state]
              [on-match]<SELECT onChange="check_tax(this.form)" NAME=state>[/on-match]
              [list]
              [loop-change 1][condition][loop-param country][/condition]
              <OPTGROUP LABEL="[data table=country col=name key='[loop-param country]']">
              [/loop-change 1]
              <OPTION VALUE="[loop-code]">[loop-pos 1]
              [/list]
              [on-match]</SELECT>[/on-match]
              [no-match]<INPUT NAME=state VALUE="[value state]" SIZE=20>[/no-match]
              [/loop]



     [comment] <input onChange="check_tax(this.form)" type=text name=state value="[value name=state filter=uc]" size=3>
    </td>[/comment]
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"> <b>[error name=zip std_label="Zip/Postal Code:" required=1]</b></div>
    </td>
    <td width="30%"> 
      <input type=text name=zip value="[value name=zip filter=word]" size="20" maxlength="10">
    </td>
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"><b>[error name=email std_label="Email Address:" required=1]</b></div>
    </td>
    <td width="30%"> 
      <input type=text name=email value="[value email]" size="20">
    </td>
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"><b>[error name=country std_label="Country:" required=1]</b> </div>
    </td>
    <td width="30%">[if value country =~ /(^$|US|CA)/] 
      <select name=country onChange="this.form.submit()">
        <option value="US"> United States 
        <option [selected country CA] value="CA"> Canada 
        <option value="JP"> Other 
      </select>
      [else] 
      <select onChange="this.form.submit()" name=country>
	[loop option=country search="
	 ra=yes
	 fi=country
	 rf=code,name
	 ml=1000
	 tf=name
	"]
	    <option value="[loop-code]"> [loop-data country name] [/loop] 
      </select>
      [/else] [/if] <small>(will update display)</small> </td>
    </tr>
  <tr> 
    <td width="25%"> 
      <div align="right"><b>[error name=phone_day std_label="Daytime Phone:" required=1]</b></div>
    </td>
    <td width="30%"> 
      <input type=text name=phone_day value="[value phone_day]" size="20" maxlength="20">
    </td>
    </tr>
  [comment]<tr> 
    <td width="25%"> 
      <div align="right">[error name=phone_night std_label="Evening Phone:" required=1]</div>
    </td>
    <td width="30%"> 
      <input type=text name=phone_night value="[value phone_night]" size="20" maxlength="20">
    </td>
    </tr>[/comment]
  <tr> 
    <td width="25%"> 
      <div align="right">Shipping method:</div>
    </td>
    <td width="30%"> 
      <select name=mv_shipmode>
      [loop option=mv_shipmode
       list=|[data table=country key='[default country US]' col=shipmodes]|
      ]
        <option value="[loop-code]"> [shipping-desc [loop-code]] [/loop] 
      </select>
    </td>
    </tr>
[seti clear_errors][error all=1 hide=1 comment="Clear errors"][/seti]


</table></td>
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" dwcopytype="CopyTableCell">
  <tr> 
    <td width="17%" bgcolor="#33CC66"><font color="#339933"></font> </td>
    <td width="6%" height="31" bgcolor="#33CC66"><font color="#FFFFFF"><b>Billing Address</b></font></td>
    </tr>
  <tr> 
    <td width="17%" height="16">&nbsp;</td>
    <td width="6%" height="16"><br></td>
    </tr>
  <tr> 
    <td width="17%" height="16">&nbsp;</td>
    <td width="6%" height="16">&nbsp;</td>
    </tr>
  <tr> 
    <td width="17%" height="21"> 
      <div align="right">Company</div>
    </td>
    <td width="6%" height="21"> 
      <input type=text name=company2 value="[value company]" size="20" maxlength="40">
    </td>
    </tr>
  <tr> 
    <td width="17%" height="16"> 
      <div align="right">First Name</div>
    </td>
    <td width="6%" height="16"> 
      <input type=text name=b_fname value="[value b_fname]" size="20" maxlength="20">
    </td>
    </tr>
  <tr> 
    <td width="17%" height="21"> 
      <div align="right">Last Name</div>
    </td>
    <td width="6%" height="21"> 
      <input type=text name=b_lname value="[value b_lname]" size="20">
    </td>
    </tr>
  <tr> 
    <td width="17%" height="18"> 
      <div align="right">Address</div>
    </td>
    <td width="6%" height="18"> 
      <input type=text name=b_address1 value="[value b_address1]" size="40" maxlength="20">
    </td>
    </tr>
  <tr> 
    <td width="17%" height="19"> 
      <div align="right"></div>
    </td>
    <td width="6%" height="19"> 
      <input type=text name=b_address2 value="[value b_address2]" size="40">
    </td>
    </tr>
  <tr> 
    <td width="17%"> 
      <div align="right">City</div>
    </td>
    <td width="6%"> 
      <input type=text name=b_city value="[value b_city]" size="20">
    </td>
    </tr>
  <tr> 
    
    <td width="17%"> 
      <div align="right">State/Province</div>
    </td>
    <td width="6%"> 

 [loop search="
                fi=state.txt
                sf=country
                se=[default country US]
                rf=state,name,country
                tf=sorder,name
                ml=100
              "
              option=state]
              [on-match]<SELECT onChange="check_tax(this.form)" NAME=state1>[/on-match]
              [list]
              [loop-change 1][condition][loop-param country][/condition]
              <OPTGROUP LABEL="[data table=country col=name key='[loop-param country]']">
              [/loop-change 1]
              <OPTION VALUE="[loop-code]">[loop-pos 1]
              [/list]
              [on-match]</SELECT>[/on-match]
              [no-match]<INPUT NAME=b_state VALUE="[value b_state]" SIZE=20>[/no-match]
              [/loop]


 [comment]     <input type=text name=b_state value="[value b_state]" size="5" maxlength="5">[/comment]
    </td>


    </tr>
  <tr> 
    <td width="17%"> 
      <div align="right">Zip/Postal Code</div>
    </td>
    <td width="6%"> 
      <input type=text name=b_zip value="[value b_zip]" size="20" maxlength="10">
    </td>
    </tr>
  <tr> 
    <td width="17%"> 
      <div align="right">Country</div>
    </td>
    <td width="6%"> 
      <input type=text name=b_country value="[value b_country]" size="20" maxlength="10">
    </td>
    </tr>
  <tr> 
    <td width="17%"> 
      <div align="right"></div>
    </td>
    <td width="6%">&nbsp;</td>
    </tr>
  <tr> 
    <td width="17%"> 
      <div align="right"></div>
    </td>
    <td width="6%">&nbsp;</td>
    </tr>
  [comment]<tr> 
    <td width="17%"> 
      <div align="right"></div>
    </td>
    <td width="6%">&nbsp;</td>
    </tr>[/comment]
  <tr> 
    <td width="17%"> 
      <div align="right"></div>
    </td>
    <td width="6%">&nbsp;</td>
    </tr>
  <tr> 
    <td width="17%">&nbsp;</td>
    <td width="6%">

[button text="Continue" src="https://www.domain.com/tools_images/images/foundation/continueaccount.gif" 
      hidetext=1 form=save] mv_nextpage=/ord/checkout [set new]1[/set] 
 [/button] 

</td>
    </tr>
</table>