Code to Insert Linebreak or Sections on Form
답변함
2024년 1월 26일에 게시됨
Hello! Was wondering if anyone has code they'd be willing to share where you have attempted to enter groups, line breaks, or sections onto a form. I thought I could possibly use JQuery to change the title of the first field in the 'section' to insert html into the title, but was wondering if anyone had other thoughts/examples. Thanks!
1
4
댓글 4개
Jakub
Hey Alek Reed could you provide more details on this use case, I am not sure I fully understand your goal, if you were able to give some more context or draft the final result how the form should look like, I will try to see if I can advise something.
1
Alek Reed
Thank you for the prompt reply Jakub!
Here is a quick rough version of what I am trying to describe. Basically, I want a group of questions to stand out as their own, so I want to interject some code for an hr break and some text or something similar.
0
Jakub
Ok, I was able to make it possible but as you said, using some jQuery and JS.
This is my snippet that I used to add a line break + a title section (h2). Additionally, I took it up a notch and added the conditional for ticket form id, this way it will only apply on one ticket form of your choice and not on all of them.
This produced the following design on the form:


Beforehand, I edited the default <hr> style to my liking:
hr {
margin: 2em auto; /* centred margin */
height: 2px; /* thickness of the line */
background-color: black; /* colour of the line */
border: none; /* no border */
}
1
Alek Reed
Wow!! Jakub - that was quick, thank you! I will test this. Very much appreciate it!
0