Streaming live at 10am (PST)

Form button - Text tied to CMS

Is it possible to tie a form button text to a field in the CMS?

Thanks!


Here is my public share link: LINK
(how to access public share link)

Hi
Do you mean the form submit button or the button to display the form?

Sorry for my delayed response. I mean the form submit button.

Not without custom code. You would basically get the value of an element, then write it back to the submit button. I am assuming you are talking about a native WF form.

@webdev that’s correct a native WF form.

It’s pretty easy to do. Example;

I have an element that has a text value from which I want to grab and then use to change the forum submit text with. Let’s say it’s a text field bound to the collection item on the collection template page with a class of "formtext ". If I place a default form on the template page, the input element with a type of "submit’ will have a class value assigned by Webflow of “w-button”.

Using jQuery I could assign the text from “formtext” to the value of “input.w-button”. It would look like this;

$(document).ready(function () {
    let btntext = $('.formtext').text();
    $('input.w-button').val(btntext); 
});

That would be placed inside an opening and closing script tag and the code would go in the template page before body close custom code area. See the university article on Custom Code.

@webdev Hello Jeff. Thank you for this solution. Do you know how I would go about changing the button text in this way for two different form buttons on the same page, each linked to a different cms field? Thanks!

@SavvyJack By targeting the right elements. See Selecting Elements | jQuery Learning Center.

Ah Okay. So I just add different classes to the two submit buttons and target those classes “.class.w-button” Thanks!