[ic] Dynamic Forms

Stephen McCullan stephen at icomtech.com
Wed Sep 24 16:39:49 EDT 2003


Dear fellow users,

Im currently implementing a checkout form that has functionality that
alters the contents of a drop down selection box based on the users
postcode. Ie the user enters his/her postcode and my code grabs the
suburb and state from a database and populates the drop down boxes. I
have got this to work no worries.

My problem is this. I wish to have the postcode field submit the value
into [value postcode] and have the form automatically refresh and thus
be able to populate the dropdowns. (Post code field is a text box. )

I can get this to work using onChange scripting, however, when I do this
the error checking code displays all the “field not completed” messages
upon the refresh.

Can anyone throw any ideas my way regarding the best way to have dynamic
forms which a textbox input submits a value and refreshes the form? Or
maybe a way I can set a flag for the error code?

Cheers, TIA


Stephen McCullan
 
 
stephen at icomtech.com
 

Code is below:



This is the dynamic form code that is included by a call from
ord/shipping.html

[if value country eq AU]
                  <tr>
                        <td align="right" class="contentbar1">
                                [error name=zip std_label="[L]4 Digit
Postal Code[/L]" required=1]
                        </td>
                        <td class="contentbar1" colspan=3>
                                <FORM NAME="postcode"
ACTION="[process-target]" METHOD=POST>
                                <input type="hidden"
name="mv_session_id" value="[data session id]">
                                <input type="hidden" name="mv_todo"
value="refresh">
                                <INPUT TYPE=text NAME=zip VALUE="[value
zip]" onChange="this.form.submit(); [seti postcode]1[/seti]">
                                </FORM>
                                Value of zip is [value zip]
                        </td>
                  </tr>
        [else]
                  <tr>
                        <td align="right" class="contentbar1">
                        </td>
                        <td class="contentbar1" colspan=3>
                                  <INPUT TYPE=text NAME=zip
VALUE="[value zip]" size="10" maxlength="10">
                        </td>
                  </tr>
        [/else]
        [/if]



This is the ord/shipping.html that performs the error checking:


    [if type=explicit compare="[error all=1 keep=1]"]
        [tmp error_display]
    <P align=left>
        <B>[L]There were errors in your last submission[/L]:<br>
        <blockquote>
        <FONT color="__CONTRAST__">
                [error all=1 keep=1 show_error=1 show_label=1
joiner="<br>"]
        </font>
        </blockquote>
        </p>
        <p>
    [msg arg.0="<FONT color='__CONTRAST__'>" arg.1="</FONT>"]The areas
you need to correct are shown in %sthis color%s below.[/msg]</B>
    </p>
    [/tmp]
    [/if]


[set Check_shipping]
        &fatal=no
        &update=yes
        __COMMON_ORDER_PROFILE__
        &fail=@@MV_PAGE@@
        &fatal=yes
        email=email
[/set]

        [comment]
                Form intro -- the input elements are largely in the
                individual tables in include/checkout/*
        [/comment]
        </td>
  </tr>
  <tr>
        <td>

        <table align="center" cellspacing=0
width="__CHECKOUT_FORM_WIDTH__">
                    <tr>
                <td class=titlebox style="padding: 12px; border-bottom:
0">
                        Shipping Address <small>[scratch
get_message]</small>
                </td>
          </tr>
        </table>


[include include/checkout/shipping_address]


        <table align="center" cellspacing=0
width="__CHECKOUT_FORM_WIDTH__">
        <tr>
                <td>&nbsp;</td>
                <td colspan="3">
                        <input type=checkbox name=mv_same_billing
value="1" [checked mv_same_billing 1]> Billing is same as this address
                        <br>
                        <br>
                        [if value address_book]
                                  <br>
                                        <u>Use account from address
book</u>:<br>

                                                <blockquote> |
                                                [loop list="[value
address_book]"]
                                                [page href=@@MV_PAGE@@
 
form="get_shipping=[loop-code]"
                                                        ][loop-code] -
[data table=userdb col=address_book.[loop-code].city key="[data session
username]" ser$
                                                [/loop]
                                                </blockquote>
    [/if]
                        [if session logged_in]
                        [page href=member/ship_addresses
form="destination=@@MV_PAGE@@"]Manage shipping addresses</a>
                        [/if]

                </td>
          </tr>
          <tr>
                <td>&nbsp;</td>
                <td colspan="3">
                <br>
                                <input type=submit value="Next --&gt;"
class=button1 style="font-weight: 500">
                </td>
          </tr>
          [if scratch error_display]
          <tr>
                <td>&nbsp;</td>
                <td colspan=3>
                <br>
                <br>
                        [scratchd error_display]
                </td>
          </tr>
          [/if]
          <tr>
                <td colspan=4>&nbsp;</td>
          </tr>
          </table>

</table>



                </td>
          </tr>

          [seti clear_errors][error all=1 hide=1 comment="Clear
errors"][/seti]

</table>
</form>



<!-- END CONTENT -->



More information about the interchange-users mailing list