Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

how to change the value for the selection using getElementsByTagName

Vote:
 

i want to chnage the value of the selection type. this selection is a default form element. so the id for IC_Club_Code is a guld which i can't use.please find the screenshot below

Episerver admin screenshot: 

what is the best way to do it. i tried the following way but it didn't work.

const onContactClick = (desc: any) => {

        const yOffsetContact = -100;
        const element = document.getElementById("divContact");
        const y = element.getBoundingClientRect().top + window.pageYOffset + yOffsetContact;

        window.scrollTo({ top: y, behavior: 'smooth' });

        var clubName = desc.ClubId.split("|")[1];

       

        const selectElement = document.getElementsByTagName("select")[1];
        selectElement.getElementsByTagName("option")[0].innerHTML = clubName;


        console.log("ClubName :", clubName);
        console.log("SelectOption:", selectElement.getElementsByTagName("option")[0].innerHTML);
    }

here is the console result:

But unfortunatly the selection vale in not chnaging in the above screenshot

#296506
Feb 14, 2023 5:58
Vote:
 

Can you not just change the value in the Selection Element within Optimizely, Or is it using a Data Feed ?

#296510
Feb 14, 2023 10:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.