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
https://forums.phpfreaks.com/topic/124323-solved-checkbox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.