CMS Development

YJoumaa
Member

Passing input from form into URL

I am very new at creating modules, so I don't quite understood other solutions to this problem.

 

What I am trying to do is create a button or use the existing button module to redirect the URL with the input from the form like this: ("https://" + input.toLowerCase() + "/accounts/login"); 

 

This is the JS that I previously had in wordpress:

 

<script>
function openSite() {
siteList = ["imi.rhonda.ai", "demo.rhonda.ai","pspc.rhonda.ai","bgrs.rhonda.ai","bluivygroup.rhonda.ai","cognex.rhonda.ai","my.rhonda.ai","trexity.rhonda.ai","hyundai.rhonda.ai","orgsoln.rhonda.ai","scorepromotions.rhonda.ai","marchnetworks.rhonda.ai","temspec.rhonda.ai"]
subdomain = document.getElementById("rhondaSite").value;
if (siteList.includes(subdomain.toLowerCase())) {
document.getElementById("errorMessage").textContent = " ";
document.getElementById("submitButton").style.color='#D0C9D6';
document.getElementById("submitButton").style.background='#ECE9F1';
url = "https://" + subdomain + "/accounts/login"
window.location.replace(url);
window.open("https://" + subdomain.toLowerCase() + "/accounts/login", "_self");
} else {
document.getElementById("errorMessage").textContent = "The company name you entered does not exist in our system, please try again or contact support@rhonda.ai";
}
}
</script>

 

 

but I how would I integrate this with a new hubspot button?

Or is there a way to use the theme button and add in the corresponding code somewhere? Would I have to edit the form code? 

 

Help would be much appreciated 🙂

0 Upvotes
1 Reply 1
Kevin-C
Recognized Expert | Partner
Recognized Expert | Partner

Passing input from form into URL

Hey @YJoumaa 

 

Take a look at this pen and compare your code.

 

As far as implementation goes, I would build a custom module for something like this. It will be much easier to reuse than trying to make a HS CTA/Button.

 

Hope this gets you moving.

Kevin Cornett - Sr. Solutions Architect @ BridgeRev
0 Upvotes