I am building a tool the builds URLs. One field in this tool is where the user enters the campaign ID. This ID corresponds to a campaign ID in our project management platform. What I am attempting to do is as the campaign ID is entered in the text field the HREF
is updated.
For example.
Simplified project management URL
:
www.projectmanagement.com?query=campaignID&showResults=False;
Campaign ID: 1234567
HREF
for the link should be:
www.projectmanagement.com?query=1234567
I've tried building a function and triggering that function with oninput(note that the field already calls one function)
The function looks something like this
function buildPMLink(){
let urlStart = "https://www.projectmanagement.com?query=";
let urlEnd = "&showResults=False";
let campRef = document.getElementByID("campid").value;
let fullURL = urlStart + campRef + urlEnd;
document.getElementById('pmURL').href = fullURL;
}
The HTML
looks like this
The field that triggers the function
<div class="input-field col s3">
<input placeholder="Enter Campaign ID" id="campid" type="text" class="validate" oninput="buildWFLink(); buildPMLink();" required >
<label for="campaign_id">Campaign ID</label>
</div>
The link I want to add the dynamic HREF too.
<div >
<a id="pmURL">Test</a>
</div>
Just doesn't seem to work. Any ideas?