Streaming live at 10am (PST)

Using JavaScript to fill in fields based on an Event Select change


#1

I can’t seem to get the select change to update the location field based on the repeater location section.


            //I have a repeater Fieldset Section tfa_1025 where fields like Event Name, Location are displayed

            //with all the campaigns the logged in owner owns

            // When the selected event is changed.

              dropdownCampaign.addEventListener(

                 'change',

                 function() { 

                     var dropdownIndex = dropdownCampaign.selectedIndex; // Index of the currently selected event

                     console.log("Current event info:\nEvent Name: " + eventNames[dropdownIndex-1]+"\nLocation: " + eventLocations[dropdownIndex-1] + "\nStatus: " + eventStatus[dropdownIndex-1] + "\nType: " + eventTypes[dropdownIndex-1] + "\nStart Date: " + eventStartDates[dropdownIndex-1] + "\nEnd Date: " + eventEndDates[dropdownIndex-1]+ "\nStart Time: " + eventStartTimes[dropdownIndex-1] + "\nEnd Time: " + eventEndTimes[dropdownIndex-1]);

                     // Logic to prefill the event name using the currently selected event field tfa_8

                     document.getElementById("tfa_8").value = eventNames[dropdownIndex-1];

                    

                    //

                    

                    // Logic to prefill the location dropdown (tfa_4) using the currently selected event

                    //tfa_1025 is the Fieldset Section displaying campaign info from owner

                      if (eventLocations[dropdownIndex-1] == "Oshawa") { 

                          SelectElement("tfa_4", "tfa_1025");

                      } else if (eventLocations[dropdownIndex-1] == "Pickering") {

                          SelectElement("tfa_4", "tfa_1025");

                      } else if (eventLocations[dropdownIndex-1] == "Whitby") {

                          SelectElement("tfa_4", "tfa_1025");

                      } 

                  },

                 false

#2

This doesn’t seem to have anything to do with Webflow. Can you provide the project share link?