KOK - MANAGER
Edit File: footer.php
<?php /** * The template for displaying the footer. * * Contains the closing of the #content div and all content after. * * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials * * @package Astra * @since 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <?php astra_content_bottom(); ?> </div> <!-- ast-container --> </div><!-- #content --> <?php astra_content_after(); astra_footer_before(); astra_footer(); astra_footer_after(); ?> </div> <!-- #page --> <a href="https://wa.me/919602694444?text=Hi" target="_blank" ><img src="https://www.e-marketing.io/wp-content/uploads/2022/06/WhatsApp.png" alt="whatsapp e-marketing" id="whatsapp" /> </a> <script> var formsData = { 6: { stateId: 'input_6_25', cityId: 'input_6_26' }, 9: { stateId: 'input_9_25', cityId: 'input_9_26' } }; jQuery(document).on('gform_post_render', function(event, formId) { if (formsData[formId]) { var stateDropdown = jQuery('#' + formsData[formId].stateId); var cityDropdown = jQuery('#' + formsData[formId].cityId); jQuery.getJSON('<?php echo get_template_directory_uri(); ?>/cities.json', function(citiesByState) { function updateCities(selectedState) { cityDropdown.empty().append(jQuery('<option></option>').val('').html('Please select a city')); if (citiesByState[selectedState] && citiesByState[selectedState].length > 0) { jQuery.each(citiesByState[selectedState], function(index, value) { cityDropdown.append(jQuery('<option></option>').val(value).html(value)); }); // Restore saved city if available var savedCity = localStorage.getItem('selectedCity_' + formId); if (savedCity && jQuery.inArray(savedCity, citiesByState[selectedState]) !== -1) { cityDropdown.val(savedCity).trigger('change'); } } } // Initial population if a default state is selected if (stateDropdown.val()) { updateCities(stateDropdown.val()); } // Change event for state selection stateDropdown.change(function() { cityDropdown.data('manual', false); // reset manual flag updateCities(jQuery(this).val()); }); // Detect manual city selection cityDropdown.change(function() { cityDropdown.data('manual', true); localStorage.setItem('selectedCity_' + formId, cityDropdown.val()); }); }).fail(function() { console.error('Could not load cities.json'); }); } }); </script> <script> jQuery(document).ready(function($){ // Define forms and their field mappings // Format: formID : { year: fieldID, month: fieldID, target: fieldID } var formsData = { 6: { year: 31, month: 34, target: 30 }, // 9: { year: 31, month: 34, target: 30 } // Example: Form 8 }; function updateNameField(formId) { var config = formsData[formId]; if (!config) return; var year = $('#input_' + formId + '_' + config.year).val(); var month = $('#input_' + formId + '_' + config.month).val(); if(year && month){ $('#input_' + formId + '_' + config.target).val(year + '/' + month); } else { $('#input_' + formId + '_' + config.target).val(''); } } // Loop through each form config $.each(formsData, function(formId, config){ // Attach change/input listeners $('#input_' + formId + '_' + config.year + ', #input_' + formId + '_' + config.month) .on('change input', function(){ updateNameField(formId); }); // Polling in case fields are dynamically populated var checkInterval = setInterval(function() { updateNameField(formId); var year = $('#input_' + formId + '_' + config.year).val(); var month = $('#input_' + formId + '_' + config.month).val(); if(year && month){ clearInterval(checkInterval); } }, 200); }); }); </script> <script> jQuery(document).ready(function($) { // Next button click par trigger $(document).on("click", ".gform_next_button", function(e) { var form = $(this).closest("form"); // jis form se button click hua var formId = form.attr("id").replace("gform_", ""); // gform_6 → 6, gform_9 → 9 var formData = {}; // Sirf current form ke input fields ka data nikal lo form.find(":input").each(function() { var input = $(this); if (input.attr("type") !== "button" && input.attr("type") !== "submit") { formData[input.attr("name")] = input.val(); } }); // AJAX call $.ajax({ url: "<?php echo admin_url('admin-ajax.php'); ?>", type: "POST", data: { action: "save_partial_entry", form_id: formId, // ✅ Form ID bhejna zaroori form_data: formData }, success: function(response) { console.log("Partial entry saved (Form " + formId + "):", response); }, error: function() { console.log("Error saving partial entry (Form " + formId + ")"); } }); }); }); </script> <?php astra_body_bottom(); wp_footer(); ?> </body> </html>