Desired outcome:
Depending on what the user enters into 'pk_AutoLyseDuration' field, change the URL in 'AutoLyse Timer URL' (pk_AL_TimerURL). 'AutoLyse Timer URL' needs to be a clickable URL.
Here is 'pk_AL_TimerURL' so far:
object: pk_AL_TimerURL
onchange event:
const AutoLyseMap = {
'.5': 'http://localhost/recipes/30-minute-timer/',
'1': 'http://localhost/recipes/timer/',
'2': 'http://localhost/recipes/2-hour-timer/',
'3': 'http://localhost/recipes/3-hour-timer/',
'4': 'http://localhost/recipes/4-hour-timer/',
'5': 'http://localhost/recipes/5-hour-timer/',
'6': 'http://localhost/recipes/6-hour-timer/',
'7': 'http://localhost/recipes/7-hour-timer/',
'8': 'http://localhost/recipes/8-hour-timer/',
};
const name = nuGetValue('pk_AutoLyseDuration'); //
nuSetValue('pk_AL_TimerURL', urlMap[name] || ''); //
What would I enter into the HTML area to accomplish the desired outcome?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Dynamic URL in HTML object Topic is solved
Re: Dynamic URL in HTML object
Hi Paul,
If you are familiar with JavaScript and/or jQuery,
you can use their functions to change different elements...
Steven
If you are familiar with JavaScript and/or jQuery,
you can use their functions to change different elements...
Code: Select all
const url = '<a href="' + $('#pk_AutoLyseDuration').val() +'">' + ' Click Me.</a>'';
$('#pk_AutoLyseDuration').html(url);
Steven
A short post is a good post.
Re: Dynamic URL in HTML object
When I place your code into the HTML tab of pk_AL_TimerURL, I get this on the form:
http://localhost/nubuilder/'+%20$('#pk_ ... ).val()%20+'
The link in the status bar is:http://localhost/nubuilder/'+%20$('#pk_ ... ).val()%20+'
You do not have the required permissions to view the files attached to this post.
Re: Dynamic URL in HTML object
Paul,
That code goes on the on blur event of your element pk_AutoLyseDuration.
Not in the HTML.
Steven
That code goes on the on blur event of your element pk_AutoLyseDuration.
Not in the HTML.
Steven
A short post is a good post.
Re: Dynamic URL in HTML object
Not sure if you understand my intended result. Re-read my original post?
-
- nuBuilder Team
- Posts: 4456
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 494 times
- Contact:
Re: Dynamic URL in HTML object
How about this? (Place it in the onblur or oninput event of pk_AutoLyseDuration)
Code: Select all
const AutoLyseMap = {
'.5': 'http://localhost/recipes/30-minute-timer/',
'1': 'http://localhost/recipes/timer/',
'2': 'http://localhost/recipes/2-hour-timer/',
'3': 'http://localhost/recipes/3-hour-timer/',
'4': 'http://localhost/recipes/4-hour-timer/',
'5': 'http://localhost/recipes/5-hour-timer/',
'6': 'http://localhost/recipes/6-hour-timer/',
'7': 'http://localhost/recipes/7-hour-timer/',
'8': 'http://localhost/recipes/8-hour-timer/',
};
const url = nuComposeURL(AutoLyseMap[this.value] || '', 'Click Me');
nuSetValue('pk_AL_TimerURL', url, 'html');
Re: Dynamic URL in HTML object
Putting that in the onInput event worked. Excellent! Thank you, Kevin!
Re: Dynamic URL in HTML object
It works, but the link dissappears when I save the record. I'd like to be able to save the html and then overwrite it (if there are changes) each time the record is saved.
-
- nuBuilder Team
- Posts: 4456
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 494 times
- Contact:
Re: Dynamic URL in HTML object
HTML elements are not stored in the database (they are display-only objects).
One option is to call
One option is to call
setTimerURL()
both in the pk_AutoLyseDuration
change event and in the form’s Custom Code when the form is loaded.Code: Select all
function setTimerURL() {
const AutoLyseMap = {
'.5': 'http://localhost/recipes/30-minute-timer/',
'1': 'http://localhost/recipes/timer/',
'2': 'http://localhost/recipes/2-hour-timer/',
'3': 'http://localhost/recipes/3-hour-timer/',
'4': 'http://localhost/recipes/4-hour-timer/',
'5': 'http://localhost/recipes/5-hour-timer/',
'6': 'http://localhost/recipes/6-hour-timer/',
'7': 'http://localhost/recipes/7-hour-timer/',
'8': 'http://localhost/recipes/8-hour-timer/',
};
const url = nuComposeURL(AutoLyseMap[nuGetValue('pk_AutoLyseDuration')] || '', 'Click Me');
nuSetValue('pk_AL_TimerURL', url, 'html');
}