Hi All,
I'm trying to do something I would consider relatively simple, but not having any luck. Wondering if someone can help me to create something on one of my confluence pages that takes user input, and directly navigates them to a URL based on their input.
Example:
User inputs 123456 and it'll take them to page: www.abc123.com/123456
User inputs 987654 and it'll take them to page www.abc123.com/987654
Wondering if anyone else has successfully implemented something similar to this? I've been able to do this in HTML, but not able to use any of the HTML Macros successfully.
Appreciate any and all Help!
Hi @JD
Welcome to the Atlassian Community.
If you are trying to add custom HTML to a Confluence page, you can use the HTML Macro.
This macro comes disabled by default so you need to work with the Confluence administrator to enable it.
Then you can insert a code similar to the below to get a text from an user.
The text is appended to a predefined URL, which is accessed clicking a button.
This code is just a sample to get you started on what you need.
<form>
<input id="thmas-input-text" type="text">
<input id="thmas-button" type="button" value="Go to link">
</form>
<script type="text/javascript">
const thmasButton = document.querySelector('#thmas-button');
const thmasInputText = document.querySelector('#thmas-input-text');
thmasButton.addEventListener('click', clickButton);
function clickButton() {
var URL = "https://www.google.com/search?q=" + thmasInputText.value;
var win = window.open(URL, "_blank");
}
</script>
Be careful when using HTML code so you don't break any other UI resource.
Make sure to test the final code before making it available to other users.
Let us know if that helps.
Kind regards,
Thiago Masutti
Hi @JD ,
Here's a link similar to your needs. You can adapted it to what you need. Instead of user. replace it with the variable field you need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.