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:


function openSite() {
siteList = ["", "","","","","","","","","","","",""]
subdomain = document.getElementById("rhondaSite").value;
if (siteList.includes(subdomain.toLowerCase())) {
document.getElementById("errorMessage").textContent = " ";
url = "https://" + subdomain + "/accounts/login"
window.location.replace(url);"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";



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 🙂

1 Reply 1
Recognized Expert | Partner

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.