Jump to content

[SOLVED] Checkbox


ainoy31

Recommended Posts

Hello-

 

I have a form that allows someone to select a checkbox called "Same as Billing Address".  When the box is checked, it calls a javascript function to disabled the other form fields.  This is working as designed.  The issue that I am dealing with is on the next page.  The user might need to come back to the checkbox page and change some of the entered data.  I added a back button to allow this.  When they click the back button, the checkmark is still on the checkbox "Same as Billing Address" but the form fields are not grayed out or disabled as needed.  Should I use the window onload?  I hope this is not confusing.  Much appreciation.  AM

 

Here is the checkbox code:

<table border="0" cellpadding="0" cellspacing="0" summary="">
<tr>
<td class="Label"><input type="checkbox" name="UBA" id="same_as_billing_address" onClick="javascript: UseBillingAddress();"></td>
<td class="Field"><label for="same_as_billing_address"><?=$langContent[$section]['same_as_billing_address'];?></label></td>
</tr>

<?php foreach($fields as $field) { ?>
<?php if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off") { ?>
<tr>
<td class="Label"><?php echo $getCustomerRulesAPI->getElement(strtoupper($field) . "_DISPLAY"); ?>:</td>
<td class="Field"><?php

 

Here is the javascript:

function UseBillingAddress()
{
if(document.dataForm.UBA.checked)
{
<?php
foreach($fields as $field)
{
if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off"){echo 'service_'.$field.' = document.dataForm.'.$field.'.value;'."\n";}
if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off"){echo 'document.dataForm.'.$field.'.value = billing_'.$field.';'."\n";}
if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off"){echo 'document.dataForm.'.$field.'.disabled = true;'."\n";}
}
echo 'service_region_id = document.dataForm.region_id.value;' . "\n";
echo 'document.dataForm.region_id.value = billing_region_id;' . "\n";
echo 'document.dataForm.region_id.disabled = true;' . "\n";
?>
}
else
{
<?php
foreach($fields as $field)
{
if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off"){echo 'document.dataForm.'.$field.'.value = service_'.$field.';'."\n";}
if($getCustomerRulesAPI->getElement(strtoupper($field) . "_STATUS") != "off"){echo 'document.dataForm.'.$field.'.disabled = false;'."\n";}
}
echo 'document.dataForm.region_id.value = service_region_id;'."\n";
echo 'document.dataForm.region_id.disabled = false;' . "\n";
?>
}
}

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.