Score:0

Use javascript code in a specific div of the webform page

sx flag

I have a website that was set up using Webforms with page breaks. So on the same URL, there are multiple "pages" and div blocks on each page, with a progress bar on top so you know what "page" you're on.

I want to repeat JavaScript code so I was thinking of using modules and/or blocks.

Can I call the specific block or code from inside the div?

For example if I make a block with js code, right now it is showing up on every "page" since they all use the same URL, when I only want it some specific places.

I would love if I could use something similar to <script src="sites/all/libraries/myfile.js"> inside an HTML markup div but I'm pretty sure this is not allowed.

Jaypan avatar
de flag
What are you trying to do? What is your end goal/use case?
taggartJ avatar
cn flag
https://www.drupal.org/docs/7/api/javascript-api/adding-javascript-to-your-theme-or-module.
Rachel C avatar
sx flag
@Jaypan The website was created by someone else and the way they set it up was with a bunch of markups on a webform. They copied and pasted the same html/js code thousands of times with just one variable changed. Now that I want to update the js code, I'm looking for a better way to separate the js and the html so we can keep the website the same and just change the js code. I hope that makes sense!
Rachel C avatar
sx flag
@taggartJ, I've tried this but I cannot figure out how to add it to a specific part of my markup instead of every "page" with the same url since it uses themes/modules
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.