Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Generate A Link Based on User Input

JD I'm New Here Apr 30, 2021

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!

2 answers

0 votes

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>

custom-html-link.png

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. smile

Let us know if that helps.

Kind regards,
Thiago Masutti

0 votes
Benjamin Community Leader Apr 30, 2021

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.

 

https://community.atlassian.com/t5/Confluence-questions/Create-a-dynamic-url-link-in-Confluence-with-username-embeded/qaq-p/330063

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,612 views 7 30
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you