Add a custom class to a script

Hi everyone ,

(My question comes from the answer Matt gave here: Pull form radio value using the label text - #3 by Matthew_Beasley)

I’d like to pull form radio value using the label text dynamic field via CMS collections.

Any chance to add a custom class to radio button in a script?


<script>
document.write('<input ');
document.write('   type="radio" ');
document.write('   name="NAME" ');
document.write('   value="VALUE">');
</script>

Well in your code, you’d just add it;

document.write('   class="CLASS" ');

However document.write is a bad idea. I’d look into doing DOM manipulations instead, or using jQuery.

This seems like an unrelated question. You can generate your radio buttons using a collection list, and Webflow’s new CMS-bound ID’s and attributes feature will work great for you here.

I know document.write is a very bad idea but I’m not able to set the radio choice value dynamically.

Thanks in advance for your help

A.