Streaming live at 10am (PST)

Dynamic Form Attributes (eg. <label name="dynamic-content-here">)


#1

Hi,

Reviving a request here by @Anna_Kelian, I'd like to be able to use dynamic content in form attributes.

I have a dynamic list of form checkboxes that I would like to associate with their form labels – as they are in a dynamic list, if I apply a name attribute to one of them it applies to all – hence I'd like to be able to use dynamic data to define the 'name' attribute so it can be clicked to activate a checkbox.

Thanks


#2

For anybody interested, I achieved this by using some Jquery. In my use-case, I needed this to build a dynamic category filter interface for dynamic lists using the great tutorial from @sabanna (hence the 'var filter' names in the code).

  • Add a dynamic text block with the text you want as the attribute and give it a class.
  • Add the code below as custom code, and edit the class in the first line of the the code below with the class from step 1.
  • Change 'for' in the last line with whatever attribute you want to change (eg. 'for', 'value', ID etc).

Please note, I'm no JQuery expert, this worked for me but feel free to suggest a better way if anybody knows!

var filter = $('.course-filter-label');
filter.each( function() {
var label = $(this);
var txt = label.text().toLowerCase();
label.attr('for', txt);
});


#3

Hi @matt50, thanks for sharing the cool workaround :slight_smile: I can completely understand the need for this to be natively built in to Webflow. Keep tuned!


#4

Thanks @cyberdave, it's usually me asking others for help so when I have a solution of my own it feels right to share! :slight_smile:


#5

@matt50 thx for reviving this request. It will be super helpful to one of my clients who has a cash-on-delivery store and whats to move to Webflow. The ability to link dynamic content to form values will make ordering both individual and multiple items (using checkboxes) super easy.


#6