formfields.com Forum Index formfields.com
FORMfields Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create A Mailing Address Same As Billing Address Checkbox

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    formfields.com Forum Index -> FF 2.X - Frequently Asked Questions (FAQs)
View previous topic :: View next topic  
Author Message
formfields



Joined: 01 Aug 2005
Posts: 465

PostPosted: Mon Oct 02, 2006 9:35 pm    Post subject: Create A Mailing Address Same As Billing Address Checkbox Reply with quote

Here is an example of how to create a form that allows the user to click a checkbox so that they don't have to enter a second address when their mailing address is the same as their billing address.

1. Use FORMgen to generate a form with the mailing and billing addresses and a checkbox:
Code:

...
$formBean = new FormBean();

$formBean->addField(new HeaderField("bill_header", "Billing Address"));
$formBean->addField(new StreetAddressField("bill_addr1", "Billing Address Line 1", REQUIRED));
$formBean->addField(new StreetAddressField("bill_addr2", "Billing Address Line 2", REQUIRED));
$formBean->addField(new CityField("bill_city", "Billing City/Town", REQUIRED));
$formBean->addField(new CityField("bill_state", "Billing State/Province", REQUIRED));
$formBean->addField(new PostalCodeField("bill_postal_code", "Billing Postal Code", REQUIRED));
$formBean->addField(new CountryField("bill_country", "Billing Country", REQUIRED, "[Select One]"));

$formBean->addField(new HeaderField("mail_header", "Mailing Address"));
$formBean->addField(new CheckboxField("mail_same", "Mailing Address Same As Billing Address"));
$formBean->addField(new StreetAddressField("mail_addr1", "Mailing Address Line 1", LOOKS_REQUIRED));
$formBean->addField(new StreetAddressField("mail_addr2", "Mailing Address Line 2", NOT_REQUIRED));
$formBean->addField(new CityField("mail_city", "Mailing City/Town", LOOKS_REQUIRED));
$formBean->addField(new CityField("mail_state", "Mailing State/Province", LOOKS_REQUIRED));
$formBean->addField(new PostalCodeField("mail_postal_code", "Mailing Postal Code", LOOKS_REQUIRED));
$formBean->addField(new CountryField("mail_country", "Mailing Country", LOOKS_REQUIRED, "[Select One]"));
...


2. Add the form name to your form tag:
Code:

...
   <form name="<?= FF_FORM_NAME ?>" action="#ffStart" method="post" enctype="multipart/form-data">
...


3. Edit the form and create JavaScript functions for disabling/enabling the mailing address:
Code:

...
<script type="text/javascript">

   // ADDED FOR EXAMPLE:
   // Disable/enable the mailing address
   function setMailingDisabled(disable) {
      <?
         if ($action != FF_DONE) {
            echo $formBean->getDisableJs("mail_addr1", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_addr2", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_city", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_state", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_postal_code", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_country", FF_FORM_NAME);
         }
      ?>
   }

   // ADDED FOR EXAMPLE:
   // If the mail_same checkbox is checked when the form loads (probably
   // when a user submits the form with an error), then disable the
   // mailing address.
   function initMailing() {
      <?
         if ($formBean->getValue("mail_same")) {
            echo "setMailingDisabled(true);";
         }
      ?>
   }
   
</script>
...


4. Add the JavaScript to the mail_same checkbox:
Code:

...
$formBean->addField(new CheckboxField("mail_same", "Mailing Address Same As Billing Address"));

// ADDED FOR EXAMPLE:
// Toggle between disabling/enabling the mailing address when the user clicks the mail_same checkbox.
$formBean->formFields["mail_same"]->setExtraHtml("onClick='setMailingDisabled(!document." . FF_FORM_NAME . ".mail_same.disabled);'");
...


5. Add functionality to ensure that a mailing address is entered when the box is not checked.
Code:

...
// ADDED FOR EXAMPLE:
// If the mail_same checkbox is not clicked
// then make sure that the user has entered a
// mailing address.
if (!$formBean->getValue("mail_same")) {
   $formBean->formFields["mail_addr1"]->checkForBlank();
   $formBean->formFields["mail_city"]->checkForBlank();
   $formBean->formFields["mail_state"]->checkForBlank();
   $formBean->formFields["mail_postal_code"]->checkForBlank();
   $formBean->formFields["mail_country"]->checkForBlank();
   $formBean->checkValues();
}

// ADDED FOR EXAMPLE:
// Ensure that there are no errors with the
// mailing address before proceeding.
if (!$formBean->isError) {
   // SUBMIT OPERATION:

   // ADDED FOR EXAMPLE:
   // Optional - you may want to copy the
   // billing address to the mailing
   // address.
   if ($formBean->getValue("mail_same")) {
      $formBean->setValue("mail_addr1", $formBean->getValue("bill_addr1"));
      $formBean->setValue("mail_addr2", $formBean->getValue("bill_addr2"));
      $formBean->setValue("mail_city", $formBean->getValue("bill_city"));
      $formBean->setValue("mail_state", $formBean->getValue("bill_state"));
      $formBean->setValue("mail_postal_code", $formBean->getValue("bill_postal_code"));
      $formBean->setValue("mail_country", $formBean->getValue("bill_country"));
   }

   $action = FF_DONE;
   if (FF_SEND_EMAIL)
      $formBean->email(FF_EMAIL, FF_FORM_TITLE . " Submission");
   if (FF_INSERT_INTO_DB) {
      $formBean->addField(new DateTimeField("__inserted_on", "Inserted On", REQUIRED, null));
      $formBean->formFields["__inserted_on"]->getCurrentDateTime();
      $formBean->insertValuesIntoDb(FF_FORM_NAME);
   }

}
...


Here is the complete example:

Code:

<? /* BEGIN - SECTION 1 */ ?>
<?php
   
   require($_SERVER["DOCUMENT_ROOT"] . "/FORMfields/FORMfields.php");
   
   //$GLOBALS["FF_VERBOSE"] = true; // For debugging purposes

   define("SLEEP", 4);
   define("FF_FORM_NAME", "samebillandmailaddress");
   define("FF_FORM_TITLE", "Same Bill And Mail Address");
   define("FF_STYLE_FILE", FF_ROOT_URL . "/styles/default.css");
   define("FF_SHOW_W3C_VALIDATOR", false);
   define("FF_DISPLAY_CONFIRMATION", false);
   define("FF_INSERT_INTO_DB", false);
   define("FF_SEND_EMAIL", false);
   define("FF_EMAIL", "");
   define("FF_CANCEL_URL", "/");
   define("FF_DONE_URL", "/");
   
   define("FF_ENTER", 1);
   define("FF_CONFIRM", 2);
   define("FF_DONE", 3);
   
   $action = FF_ENTER;

   $formBean = new FormBean();
   $formBean->addField(new SubmitField("_submit", "Submit"));
   $formBean->addField(new SubmitField("clear", "Clear"));
   $formBean->addField(new SubmitField("cancel", "Cancel"));

   $formBean->addField(new HeaderField("bill_header", "Billing Address"));
   $formBean->addField(new StreetAddressField("bill_addr1", "Billing Address Line 1", REQUIRED));
   $formBean->addField(new StreetAddressField("bill_addr2", "Billing Address Line 2", REQUIRED));
   $formBean->addField(new CityField("bill_city", "Billing City/Town", REQUIRED));
   $formBean->addField(new CityField("bill_state", "Billing State/Province", REQUIRED));
   $formBean->addField(new PostalCodeField("bill_postal_code", "Billing Postal Code", REQUIRED));
   $formBean->addField(new CountryField("bill_country", "Billing Country", REQUIRED, "[Select One]"));

   $formBean->addField(new HeaderField("mail_header", "Mailing Address"));
   
   $formBean->addField(new CheckboxField("mail_same", "Mailing Address Same As Billing Address"));
   
   // ADDED FOR EXAMPLE:
   // Toggle between disabling/enabling the mailing address when the user clicks the mail_same checkbox.
   $formBean->formFields["mail_same"]->setExtraHtml("onClick='setMailingDisabled(!document." . FF_FORM_NAME . ".mail_same.disabled);'");
   
   $formBean->addField(new StreetAddressField("mail_addr1", "Mailing Address Line 1", LOOKS_REQUIRED));
   $formBean->addField(new StreetAddressField("mail_addr2", "Mailing Address Line 2", NOT_REQUIRED));
   $formBean->addField(new CityField("mail_city", "Mailing City/Town", LOOKS_REQUIRED));
   $formBean->addField(new CityField("mail_state", "Mailing State/Province", LOOKS_REQUIRED));
   $formBean->addField(new PostalCodeField("mail_postal_code", "Mailing Postal Code", LOOKS_REQUIRED));
   $formBean->addField(new CountryField("mail_country", "Mailing Country", LOOKS_REQUIRED, "[Select One]"));
   
   if (FormField::getOrNull("_confirm", $_REQUEST) || FormField::getOrNull("_back", $_REQUEST)) {
      $formBean->setEditable(false);
   }

   $formBean->getParameters();
   
   if (FormField::getOrNull("_back", $_REQUEST)) {
      $formBean->setEditable(true);
   }
   
   if (FormField::getOrNull("_submit", $_REQUEST) || FormField::getOrNull("_confirm", $_REQUEST)) {
      if ($formBean->checkValues()) {
         if (FF_DISPLAY_CONFIRMATION && !FormField::getOrNull("_confirm", $_REQUEST)) {
            // CONFIRMATION OPERATION:
            $formBean->setEditable(false);
            $formBean->addField(new SubmitField("_back", "< Back"));
            $formBean->addField(new SubmitField("_confirm", "Confirm >"));
            $action = FF_CONFIRM;
         } else {
         
            // ADDED FOR EXAMPLE:
            // If the mail_same checkbox is not clicked
            // then make sure that the user has entered a
            // mailing address.
            if (!$formBean->getValue("mail_same")) {
               $formBean->formFields["mail_addr1"]->checkForBlank();
               $formBean->formFields["mail_city"]->checkForBlank();
               $formBean->formFields["mail_state"]->checkForBlank();
               $formBean->formFields["mail_postal_code"]->checkForBlank();
               $formBean->formFields["mail_country"]->checkForBlank();
               $formBean->checkValues();
            }

            // ADDED FOR EXAMPLE:
            // Ensure that there are no errors with the
            // mailing address before proceeding.
            if (!$formBean->isError) {
               // SUBMIT OPERATION:

               // ADDED FOR EXAMPLE:
               // Optional - you may want to copy the
               // billing address to the mailing
               // address.
               if ($formBean->getValue("mail_same")) {
                  $formBean->setValue("mail_addr1", $formBean->getValue("bill_addr1"));
                  $formBean->setValue("mail_addr2", $formBean->getValue("bill_addr2"));
                  $formBean->setValue("mail_city", $formBean->getValue("bill_city"));
                  $formBean->setValue("mail_state", $formBean->getValue("bill_state"));
                  $formBean->setValue("mail_postal_code", $formBean->getValue("bill_postal_code"));
                  $formBean->setValue("mail_country", $formBean->getValue("bill_country"));
               }

               $action = FF_DONE;
               if (FF_SEND_EMAIL)
                  $formBean->email(FF_EMAIL, FF_FORM_TITLE . " Submission");
               if (FF_INSERT_INTO_DB) {
                  $formBean->addField(new DateTimeField("__inserted_on", "Inserted On", REQUIRED, null));
                  $formBean->formFields["__inserted_on"]->getCurrentDateTime();
                  $formBean->insertValuesIntoDb(FF_FORM_NAME);
               }
               
            }
         }
      }
   } else if (FormField::getOrNull("clear", $_REQUEST)) {
      // CLEAR OPERATION:
      $formBean->clearAllData();
   } else if (FormField::getOrNull("cancel", $_REQUEST)) {
      // CANCEL OPERATION:
      header("Location: " . FF_CANCEL_URL);
   } else if (!$formBean->getButtonClicked()) {
      // DEFAULT OPERATION:
      // Enter default values here. Example:
      // $formBean->setValue("name", "John");
   }
   
?>
<? /* END - SECTION 1 */ ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><?= FF_FORM_TITLE ?></title>
<? /* BEGIN - SECTION 2 */ ?>
<? if ($action == FF_DONE) { ?>
   <meta http-equiv="Refresh" content="<?= SLEEP ?>; url=<?= FF_DONE_URL ?>">
<? } ?>
<link rel="stylesheet" type="text/css" href="<?= FF_ROOT_URL ?>/FORMfields.css" />
<script type="text/javascript" src="<?= FF_ROOT_URL ?>/FORMfields.js"></script>
<script type="text/javascript">

   // ADDED FOR EXAMPLE:
   // Disable/enable the mailing address
   function setMailingDisabled(disable) {
      <?
         if ($action != FF_DONE) {
            echo $formBean->getDisableJs("mail_addr1", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_addr2", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_city", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_state", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_postal_code", FF_FORM_NAME);
            echo $formBean->getDisableJs("mail_country", FF_FORM_NAME);
         }
      ?>
   }

   // ADDED FOR EXAMPLE:
   // If the mail_same checkbox is checked when the form loads (probably
   // when a user submits the form with an error), then disable the
   // mailing address.
   function initMailing() {
      <?
         if ($formBean->getValue("mail_same")) {
            echo "setMailingDisabled(true);";
         }
      ?>
   }
   
</script>

<link rel="stylesheet" type="text/css" href="<?= FF_ROOT_URL ?>/tableHelpers.css" />
<link rel="stylesheet" type="text/css" href="<?= FF_STYLE_FILE ?>" />
<style type="text/css">
   /* Sometimes it is useful to specify a label width */
   /*label.notValid, label.isValid, label.disabled, label.display {
      width: 150px;
   }*/
</style>
<? /* END - SECTION 2 */ ?>
</head>

<body onload="setFocus();initMailing();" class="FORMfields">
<? /* BEGIN - SECTION 3 */ ?>
   <table>
   <tr>
   <td>
   <a name="ffStart"></a>
   <form name="<?= FF_FORM_NAME ?>" action="#ffStart" method="post" enctype="multipart/form-data">
      <div class="FORMfields">
         <h1 class="FORMfields"><?= FF_FORM_TITLE ?></h1>
         <? if ($action == FF_DONE) { ?>
            <br />
            <div style="font: normal normal bold 18px verdana;">
               Thank you for your submission.
            </div>
            <div style="margin-top:20px;font: normal normal bold 12px verdana;">
               Note: Please click <a href="/">here</a> if your browser does not redirect in <?= SLEEP ?> seconds.
            </div>
            <br />
         <? } else {
            if ($action == FF_CONFIRM) {
               ?>
                  <h3 class="FORMfields">
                     Please confirm that the following data is correct:
                  </h3>
               <?
            } else {
               ?>
                  <div style="text-align:right;">
                     <span class="required">*</span><span class="help" style="padding-left:0px;font-size:9px;"> - required</span>
                  </div>
               <?
            }
            
            echo $formBean->getTableTag();
         } ?>
         
      </div>
      <div style="text-align:left;margin:10px 3px 10px 3px;">
         <a style="font: normal normal normal 9px verdana,sans-serif;" href="http://www.formfields.com" target="_blank">Form Generated by FORMgen</a>
      </div>
      <? if (FF_SHOW_W3C_VALIDATOR) { ?>
         <div>
            <a href="http://validator.w3.org/check?uri=referer"><img border="0" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
            <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
         </div>
      <? } ?>
   </form>
   </td>
   </tr>
   </table>
<? /* END - SECTION 3 */ ?>
</body>

</html>
Back to top
View user's profile Send private message
formfields



Joined: 01 Aug 2005
Posts: 465

PostPosted: Thu Nov 02, 2006 4:49 pm    Post subject: Reply with quote

Alternatively, if you would like the mailing address to be dynamically populated with the billing address using JavaScript when the user clicks "Mailing Address Same As Billing Address" then you could use the following form:
Code:

<? /* BEGIN - SECTION 1 */ ?>
<?php
   
   require($_SERVER["DOCUMENT_ROOT"] . "/FORMfields/FORMfields.php");
   
   //$GLOBALS["FF_VERBOSE"] = true; // For debugging purposes

   define("SLEEP", 4);
   define("FF_FORM_NAME", "samebillandmailaddress");
   define("FF_FORM_TITLE", "Same Bill And Mail Address");
   define("FF_STYLE_FILE", FF_ROOT_URL . "/styles/default.css");
   define("FF_SHOW_W3C_VALIDATOR", false);
   define("FF_DISPLAY_CONFIRMATION", false);
   define("FF_INSERT_INTO_DB", false);
   define("FF_SEND_EMAIL", false);
   define("FF_EMAIL", "");
   define("FF_CANCEL_URL", "/");
   define("FF_DONE_URL", "/");
   
   define("FF_ENTER", 1);
   define("FF_CONFIRM", 2);
   define("FF_DONE", 3);
   
   $action = FF_ENTER;

   $formBean = new FormBean();
   $formBean->addField(new SubmitField("_submit", "Submit"));
   $formBean->addField(new SubmitField("clear", "Clear"));
   $formBean->addField(new SubmitField("cancel", "Cancel"));

   $formBean->addField(new HeaderField("bill_header", "Billing Address"));
   $formBean->addField(new StreetAddressField("bill_addr1", "Billing Address Line 1", REQUIRED));
   $formBean->addField(new StreetAddressField("bill_addr2", "Billing Address Line 2", REQUIRED));
   $formBean->addField(new CityField("bill_city", "Billing City/Town", REQUIRED));
   $formBean->addField(new CityField("bill_state", "Billing State/Province", REQUIRED));
   $formBean->addField(new PostalCodeField("bill_postal_code", "Billing Postal Code", REQUIRED));
   $formBean->addField(new CountryField("bill_country", "Billing Country", REQUIRED, "[Select One]"));

   $formBean->addField(new HeaderField("mail_header", "Mailing Address"));
   
   $formBean->addField(new CheckboxField("mail_same", "Mailing Address Same As Billing Address"));
   
   // ADDED FOR EXAMPLE:
   // Toggle between disabling/enabling the mailing address when the user clicks the mail_same checkbox.
   $formBean->formFields["mail_same"]->setExtraHtml("onClick='toggleMailingSame();'");
   
   $formBean->addField(new StreetAddressField("mail_addr1", "Mailing Address Line 1", LOOKS_REQUIRED));
   $formBean->addField(new StreetAddressField("mail_addr2", "Mailing Address Line 2", NOT_REQUIRED));
   $formBean->addField(new CityField("mail_city", "Mailing City/Town", LOOKS_REQUIRED));
   $formBean->addField(new CityField("mail_state", "Mailing State/Province", LOOKS_REQUIRED));
   $formBean->addField(new PostalCodeField("mail_postal_code", "Mailing Postal Code", LOOKS_REQUIRED));
   $formBean->addField(new CountryField("mail_country", "Mailing Country", LOOKS_REQUIRED, "[Select One]"));
   
   if (FormField::getOrNull("_confirm", $_REQUEST) || FormField::getOrNull("_back", $_REQUEST)) {
      $formBean->setEditable(false);
   }

   $formBean->getParameters();
   
   if (FormField::getOrNull("_back", $_REQUEST)) {
      $formBean->setEditable(true);
   }
   
   if (FormField::getOrNull("_submit", $_REQUEST) || FormField::getOrNull("_confirm", $_REQUEST)) {
      if ($formBean->checkValues()) {
         if (FF_DISPLAY_CONFIRMATION && !FormField::getOrNull("_confirm", $_REQUEST)) {
            // CONFIRMATION OPERATION:
            $formBean->setEditable(false);
            $formBean->addField(new SubmitField("_back", "< Back"));
            $formBean->addField(new SubmitField("_confirm", "Confirm >"));
            $action = FF_CONFIRM;
         } else {
         
            // ADDED FOR EXAMPLE:
            // If the mail_same checkbox is not clicked
            // then make sure that the user has entered a
            // mailing address.
            if (!$formBean->getValue("mail_same")) {
               $formBean->formFields["mail_addr1"]->checkForBlank();
               $formBean->formFields["mail_city"]->checkForBlank();
               $formBean->formFields["mail_state"]->checkForBlank();
               $formBean->formFields["mail_postal_code"]->checkForBlank();
               $formBean->formFields["mail_country"]->checkForBlank();
               $formBean->checkValues();
            }

            // ADDED FOR EXAMPLE:
            // Ensure that there are no errors with the
            // mailing address before proceeding.
            if (!$formBean->isError) {
               // SUBMIT OPERATION:

               // ADDED FOR EXAMPLE:
               // Optional - you may want to copy the
               // billing address to the mailing
               // address.
               if ($formBean->getValue("mail_same")) {
                  $formBean->setValue("mail_addr1", $formBean->getValue("bill_addr1"));
                  $formBean->setValue("mail_addr2", $formBean->getValue("bill_addr2"));
                  $formBean->setValue("mail_city", $formBean->getValue("bill_city"));
                  $formBean->setValue("mail_state", $formBean->getValue("bill_state"));
                  $formBean->setValue("mail_postal_code", $formBean->getValue("bill_postal_code"));
                  $formBean->setValue("mail_country", $formBean->getValue("bill_country"));
               }

               $action = FF_DONE;
               if (FF_SEND_EMAIL)
                  $formBean->email(FF_EMAIL, FF_FORM_TITLE . " Submission");
               if (FF_INSERT_INTO_DB) {
                  $formBean->addField(new DateTimeField("__inserted_on", "Inserted On", REQUIRED, null));
                  $formBean->formFields["__inserted_on"]->getCurrentDateTime();
                  $formBean->insertValuesIntoDb(FF_FORM_NAME);
               }
               
            }
         }
      }
   } else if (FormField::getOrNull("clear", $_REQUEST)) {
      // CLEAR OPERATION:
      $formBean->clearAllData();
   } else if (FormField::getOrNull("cancel", $_REQUEST)) {
      // CANCEL OPERATION:
      header("Location: " . FF_CANCEL_URL);
   } else if (!$formBean->getButtonClicked()) {
      // DEFAULT OPERATION:
      // Enter default values here. Example:
      // $formBean->setValue("name", "John");
   }
   
?>
<? /* END - SECTION 1 */ ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title><?= FF_FORM_TITLE ?></title>
<? /* BEGIN - SECTION 2 */ ?>
<? if ($action == FF_DONE) { ?>
   <meta http-equiv="Refresh" content="<?= SLEEP ?>; url=<?= FF_DONE_URL ?>">
<? } ?>
<link rel="stylesheet" type="text/css" href="<?= FF_ROOT_URL ?>/FORMfields.css" />
<script type="text/javascript" src="<?= FF_ROOT_URL ?>/FORMfields.js"></script>
<script type="text/javascript">

   // ADDED FOR EXAMPLE:
   // Disable/enable the mailing address
   function toggleMailingSame() {
      <?
         if ($action != FF_DONE) {
            ?>
               if (document.samebillandmailaddress.mail_same.checked) {
                  document.samebillandmailaddress.mail_addr1.value = document.samebillandmailaddress.bill_addr1.value;
                  document.samebillandmailaddress.mail_addr2.value = document.samebillandmailaddress.bill_addr2.value;
                  document.samebillandmailaddress.mail_city.value = document.samebillandmailaddress.bill_city.value;
                  document.samebillandmailaddress.mail_state.value = document.samebillandmailaddress.bill_state.value;
                  document.samebillandmailaddress.mail_postal_code.value = document.samebillandmailaddress.bill_postal_code.value;
                  document.samebillandmailaddress.mail_country.value = document.samebillandmailaddress.bill_country.value;
               } else {
                  document.samebillandmailaddress.mail_addr1.value = '';
                  document.samebillandmailaddress.mail_addr2.value = '';
                  document.samebillandmailaddress.mail_city.value = '';
                  document.samebillandmailaddress.mail_state.value = '';
                  document.samebillandmailaddress.mail_postal_code.value = '';
                  document.samebillandmailaddress.mail_country.value = '';
               }
            <?
         }
      ?>
   }

   // ADDED FOR EXAMPLE:
   // If the mail_same checkbox is checked when the form loads (probably
   // when a user submits the form with an error), then disable the
   // mailing address.
   function initMailing() {
      <?
         if ($formBean->getValue("mail_same")) {
            echo "toggleMailingSame();";
         }
      ?>
   }
   
</script>

<link rel="stylesheet" type="text/css" href="<?= FF_ROOT_URL ?>/tableHelpers.css" />
<link rel="stylesheet" type="text/css" href="<?= FF_STYLE_FILE ?>" />
<style type="text/css">
   /* Sometimes it is useful to specify a label width */
   /*label.notValid, label.isValid, label.disabled, label.display {
      width: 150px;
   }*/
</style>
<? /* END - SECTION 2 */ ?>
</head>

<body onload="setFocus();initMailing();" class="FORMfields">
<? /* BEGIN - SECTION 3 */ ?>
   <table>
   <tr>
   <td>
   <a name="ffStart"></a>
   <form name="<?= FF_FORM_NAME ?>" action="#ffStart" method="post" enctype="multipart/form-data">
      <div class="FORMfields">
         <h1 class="FORMfields"><?= FF_FORM_TITLE ?></h1>
         <? if ($action == FF_DONE) { ?>
            <br />
            <div style="font: normal normal bold 18px verdana;">
               Thank you for your submission.
            </div>
            <div style="margin-top:20px;font: normal normal bold 12px verdana;">
               Note: Please click <a href="/">here</a> if your browser does not redirect in <?= SLEEP ?> seconds.
            </div>
            <br />
         <? } else {
            if ($action == FF_CONFIRM) {
               ?>
                  <h3 class="FORMfields">
                     Please confirm that the following data is correct:
                  </h3>
               <?
            } else {
               ?>
                  <div style="text-align:right;">
                     <span class="required">*</span><span class="help" style="padding-left:0px;font-size:9px;"> - required</span>
                  </div>
               <?
            }
            
            echo $formBean->getTableTag();
         } ?>
         
      </div>
      <div style="text-align:left;margin:10px 3px 10px 3px;">
         <a style="font: normal normal normal 9px verdana,sans-serif;" href="http://www.formfields.com" target="_blank">Form Generated by FORMgen</a>
      </div>
      <? if (FF_SHOW_W3C_VALIDATOR) { ?>
         <div>
            <a href="http://validator.w3.org/check?uri=referer"><img border="0" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
            <a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
         </div>
      <? } ?>
   </form>
   </td>
   </tr>
   </table>
<? /* END - SECTION 3 */ ?>
</body>

</html>
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    formfields.com Forum Index -> FF 2.X - Frequently Asked Questions (FAQs) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group