@@ -373,48 +418,76 @@ $(document).ready(function() {
//---------VENKAT-----------------------------------------------------------------------------------
// for Additional Product Name Edit Purpose
- var additionalProductName = = json_encode($additionalProdutName) ?>;
+ // var additionalProductName = = json_encode($additionalProdutName) ?>;
+ // if (Array.isArray(additionalProductName) && additionalProductName.length > 0) {
- // console.log(additionalProductName);
- // console.log(additionalProductName.length);
-
- if (Array.isArray(additionalProductName) && additionalProductName.length > 0) {
-
- var firstProductName = '= isset($products['product_name']) ? $products['product_name'] : '' ?>';
- console.log('firstProductName', firstProductName);
- additionalProductName.forEach(function(item) {
- if (firstProductName !== item.additional_product_name) {
- addHTMLInput(item); // for if edit
- }
- });
- if(additionalProductName.length == 1){
- addHTMLInput()
- }
- } else {
- addHTMLInput(); // for else add
- }
+ // var firstProductName = '= isset($products['product_name']) ? $products['product_name'] : '' ?>';
+ // console.log('firstProductName', firstProductName);
+ // additionalProductName.forEach(function(item) {
+ // if (firstProductName !== item.additional_product_name) {
+ // addHTMLInput(item); // for if edit
+ // }
+ // });
+ // if(additionalProductName.length == 1){
+ // addHTMLInput()
+ // }
+ // } else {
+ // addHTMLInput(); // for else add
+ // }
// end of Additional Product Name Edit Purpose
//------------------------------------------------------------------------------------------------
});
-/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */
-// $(document).ready(function() {
-// function calculateTotalAmount() {
-// var unitPrice = parseFloat($("input[name='unit_price']").val());
-// var tax = parseFloat($("select[name='tax']").val());
-// var totalAmount = unitPrice + (unitPrice * tax / 100);
-// $("input[name='total_amount']").val(totalAmount.toFixed(2));
-// }
+const $dynamicContainer = $("#dynamic-form-container");
-// $("input[name='unit_price'], select[name='tax']").change(function() {
-// calculateTotalAmount();
-// });
+$("#model").change(function () {
+ const selectedOptions = $(this).find("option:selected");
-// calculateTotalAmount();
-// });
+ // Loop through the selected options
+ selectedOptions.each(function () {
+ const modelId = $(this).val(); // Value of the make option
+ const modelName = $(this).text(); // Name of the make option
+ // Check if the field already exists
+ if (!$(`#field_${modelId}`).length) {
+ // Fields to append
+ const fieldSet = `
+
+ `;
+
+ // Append the new field
+ $("#dynamic-form-container").append(fieldSet);
+ }
+ });
+
+ // Remove fields for deselected options
+ $("#dynamic-form-container").find(".form-row").each(function () {
+ const fieldId = $(this).attr("id");
+ const modelId = fieldId.split("_")[1]; // Extract modelId from the field's id
+
+ // If the model is no longer selected, remove the field
+ if (!$(`#model option[value='${modelId}']`).is(":selected")) {
+ $(this).remove();
+ }
+ });
+
+
+});
$(document).ready(function() {
// Check SGST checkbox by default
@@ -525,26 +598,7 @@ $('#qty_in_stock').on('keyup change', function() {
-
+
-
+