I am building a custom site where users can pick a container, pick from a variety of stuffers, and then select shipping method.
Everything works fine on Chrome, but I noticed that Safari is acting weird.
The numbers should automatically change based on user input, which happens on Chrome. When the quantity is changed, the total changes, when an item is added, the cost per item and total cost per items changes. When quantity is changed, shipping/handling costs change as well.
It seems as though on Safari, that when I make a change, it takes another change to be made in order for the previous change to display. Also, when inputting a number into the quantity directly, it does not calculate correctly, cannot pinpoint exactly what.
You have thousands of code lines on your page, so it might not be easy to locate the issue (you can make it much shorter. I mean MUCH shorter by using functions and methods for repeated code).
Anyhow, I can see you have some imports in the middle of your code (See lines: 2196-2199), you should move them to the top of the page, but I doubt that will solve the issue.
I suggest:
Make the code shorter.
Check the safari console and see if there’s any error.
Add console.log() to the relevant places and debug the code.
Try to see if using onKeyPress with setTimeout(callback, 10) instead of onInput solves the problem.
@bizlutionsllc there’re many ways to things shorter.
For example, lets say you have many single checkboxes on your page and you wish that once one of them is checked the others will get disabled.
Then instead of creating a separate event handler to each of them, and disable each separately, you can do something like:
@jonatandor35 Thank you! this helps a lot! However, in this case, it would have to be certain checkboxes. For example, if they select a container, only the container checkboxes are disabled. If a Bow Color is selected, only the bow options are disabled. Any suggestions on how to edit this?
@jonatandor35 Also, am I able to condense the “if checkbox 24 is checked” lines. These are pushing different values to different data fields, if the one checkbox is checked.
$w('#dataset1').onBeforeSave(() => {
let checked = [];
//ORDER INFORMATION
if ($w('#checkbox24').checked) {
checked.push($w('#input28').value)
$w('#dataset1').setFieldValue('ordernumber', checked);}
if ($w('#checkbox24').checked) {
checked.push($w('#text145').text)
$w('#dataset1').setFieldValue('container', checked);}
if ($w('#checkbox24').checked) {
checked.push($w('#text146').text)
$w('#dataset1').setFieldValue('containerColor', checked);}
if ($w('#checkbox24').checked) {
checked.push($w('#input13').value)
$w('#dataset1').setFieldValue('quantity', checked);}
if ($w('#checkbox24').checked) {
checked.push($w('#input26').value)
$w('#dataset1').setFieldValue('costPerItem', checked);}
if ($w('#checkbox24').checked) {
checked.push($w('#input33').value)
$w('#dataset1').setFieldValue('handlingCost', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input34').value)
$w('#dataset1').setFieldValue('shippingEstimate', checked);}
if ($w('#checkbox24').checked) {
checked.push($w("#input26").value);
$w('#dataset1').setFieldValue('totalCostOfItems', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input20').value)
$w('#dataset1').setFieldValue('shippingCompanyName', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input19').value);
$w('#dataset1').setFieldValue('shippingContactName', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input21').value);
$w('#dataset1').setFieldValue('shippingAddress', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input22').value);
$w('#dataset1').setFieldValue('shippingAddress2', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input18').value);
$w('#dataset1').setFieldValue('shippingCity', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input17').value);
$w('#dataset1').setFieldValue('shippingStaate', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input16').value);
$w('#dataset1').setFieldValue('shippingZip', checked); }
if ($w('#checkbox16').checked) {
checked.push($w('#input24').value);
$w('#dataset1').setFieldValue('shippingPhone', checked); }
if ($w('#checkbox17').checked) {
checked.push($w('#uploadButton1').uploadFiles());
$w('#dataset1').setFieldValue('addressList', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input6').value);
$w('#dataset1').setFieldValue('title', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input7').value);
$w('#dataset1').setFieldValue('billingContactName', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input14').value);
$w('#dataset1').setFieldValue('billingAddress1', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input15').value);
$w('#dataset1').setFieldValue('billingAddress2', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input8').value);
$w('#dataset1').setFieldValue('billingCity', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input9').value);
$w('#dataset1').setFieldValue('billingState', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input10').value);
$w('#dataset1').setFieldValue('billingZip', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input11').value);
$w('#dataset1').setFieldValue('contactEmail', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#input12').value);
$w('#dataset1').setFieldValue('contactPhone', checked); }
//BOW COLORS
if ($w('#checkbox24').checked) {
checked.push($w('#text123').text);
$w('#dataset1').setFieldValue('bowColor', checked); }
if ($w('#checkbox24').checked) {
checked.push($w('#text145').text);
$w('#dataset1').setFieldValue('stuffers', checked); }
//SHIPPING METHOD LABELS TO DATABASE
if ($w('#checkbox16').checked) {
checked.push('To One Location');
$w('#dataset1').setFieldValue('shippingMethod', checked); }
if ($w('#checkbox17').checked) {
checked.push('To Multiple Locations');
$w('#dataset1').setFieldValue('shippingMethod', checked); }
//HANG TAG LABELS TO DATABASE
{
if ($w('#checkbox19').checked) {
checked.push('Yes');
$w('#dataset1').setFieldValue('hangTag', checked); }
else {
$w('#dataset1').setFieldValue('hangTag', "No"); }
}
});