Rich-text Reply

Javascript - Show/hide form field when radio button is pressed!!!

rosted 03-15-17

Javascript - Show/hide form field when radio button is pressed!!!

Hey.

I want to add a simple piece of javascript code to a variation.
What it should do:

When a specific radio button is "checked" a hidden form field should change state from hidden to visibil!!!

I know, its very simple, but for some reason I can´t get the script to run!!!

 

The JS function I have made and added to the Experiment Javascript is undefined in the preview!!!

 

A little help would be really appriciated.

Ps. I´ve have googled and searched the forum. But could´nt find anything that answers my question Smiley Sad

 

Thanks

Level 1

Dyel 03-20-17
 

Re: Javascript - Show/hide form field when radio button is pressed!!!

Hi,

Thanks for reaching out to the Optimizely community! I am part of the support team. I will be sending you a private message in order to get more insight on the issue you are facing.

Kind regards,
Dyel
Optimizely
JasonDahlin 03-20-17
 

Re: Javascript - Show/hide form field when radio button is pressed!!!

Have you been able to get it to work when you run everything in your browser's console?
You should totally be able to have the code look at the page when it loads to see if the radio is checked or not and reveal the form and also add a listener to the radio button that does a show/hide for when the radio button because checked/unchecked.

Can you post what you have so far and a link to the page with the form?
--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero