If/Then Logic

Well after a couple weeks, I’m still more Dummy than Dangerous, but with the help of Giri’s suggestion, a JavaScript for Dummies book, Wix Code API Reference, Webix Desgns by Nayeli on YouTube, w3schools and a lot of trial and error, I got this to work!

My page is a Dynamic page showing the detail of one order item. The page has a Quantity ordered (“#qtyinput”) field and a Picked (“#checkbox1”) field.

  1. Once the ordered item is picked from stock, the Picked (“#checkbox1”) is checked.
  2. When the order is packed, the Quantity ordered (“#qtyinput”) field is entered as 0 (zero).

Now the page automatically unchecks the Picked checkbox whenever the Quantity ordered = 0

Here is the code that did it for me:

$w.onReady( () => {

$w("#dynamicDataset").onReady( () => {          // Allow dataset to load 

	$w("#qtyinput").onChange( () => {  		// Monitor Qty (#qtyinput) field for a change in value 
		 
	var itemQty = $w("#qtyinput").value;  	// Declare var itemQty = to "#qtyinput" field value 

		if (itemQty < 1) {				// If "#qtyinput" (Qty) field is 0, do the next line 
		
			$w("#checkbox1").checked = false;	     // Set "#checkbox1" field to unchecked 
	  		$w("#dynamicDataset").setFieldValue("pickUp", false);      // Update Collection 
		} 

	});  
	
});	 

}); // end

P.S. It boggles my mind, what WIX has accomplished with its website building environment. Thanks to everyone at WIX for your hard work and dedication.