- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2015 07:04 AM
Hello, I dont know how to set variable value to UI macro.
I have UI macro below and onchange client script
Onchange client script is able to alert me with variable, but I doesnt need alert, need to set this value to UI macro on form. So when user select value in field A, html data should be populated to field B ( field B is UI macro )
How can I do it ? Should I better create some UI page and pass data through ?
Actually I will need to pass html value to UI macro field through onchange wizard script.
thank you
/Petr
UI macro
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<html>
<head>
<script>
function checkDetails()
{
var selected_training = g_form.getReference('u_select_training');
var u_selected_training_description = selected_training.short_description;
alert('from date :'+u_selected_training_description);
}
</script>
</head>
</html>
</j:jelly>
Wizard Client Script
function onChange(control, oldValue, newValue, isLoading) {
if (!isLoading){
checkDetails();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2015 09:46 AM
If I understand it right, it's fairly easy.
This is what I understood so far:
- You want to set a HTML field on the UI Macro with the Short_Description of the select training field on the form.
- One thing that's missing is the HTML of the field in the UI Macro.
Here is very small snippet I have set up:
My UI Macro has a field called "short description" which is an input, which I will be setting on Change of a field on the form. Here is the UI Macro. Notice the Script that's inside the UI Macro:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
Short Description: <input id="short_description" type="text"/>
<script>
function setDesc(text){
$j("#short_description").val(text);
}
</script>
</j:jelly>
Now, the easy part : write an onChange script to call the setDesc. Because `setDesc` is loaded on the global name space you should be able to call it like this:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
setDesc(newValue);
//Type appropriate comment here, and begin script below
}
Does that help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2015 04:05 AM
instead of text field use a div in macro. it will render the html content very well. Also change the type of variable to macro with label and add question 'Short Description:' . macro should have following type of code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div id="short_description"/>
<script>
function setDesc(text){
document.getElementById('short_description').innerHTML = text;
}
</script>
</j:jelly>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-19-2015 04:36 AM
Gurpreet, fully correct answer to my question!!! thank You,
it is solved for me now.
I made notes about that for the future. Its sometimes hard get in to codes when not working with them every day.
Below is an image of how it looks like when training is selected. I also created wizard UI policy to hide macro if training field is empty so the macro label doesn't disturb/confuse users
Thanks a lot for your time on this, very appreciate this
/Petr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2015 01:09 PM
Thank you for this solution - I great solution to get your Links on the catalog form since there is no URL Catalog variable type available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 07:27 PM
Do you know how I can pass a url to a ui macro so that it will display on my catalog item in this manner:
I am building a url on change of a variable on my catalog item but a client script making an ajax call to a table with some specific values. So I return a url that is similar to this:
https://xxxxxxxx.wustl.edu/docid=1234&invid=65434&docdept=65434
I want this to then display on my catalog item more like this:
Click here to View Image
I am thinking I need to use a UI Macro variable. i am able to pass the url to the ui macro but I can't figure out how to then get the code in the ui macro to be able to insert it into the <a href tag.
Any help would be appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2016 09:23 PM
Hi Rhonda,
Suppose u are having url in a variable called url then u just need to build HTML String as follow
var url = 'https://google.com' ; //get it using ajax
var text = '<a target="_blank" href="'+url+'">Here</a>' ;
//then use the same function (setDesc) to set above html in the macro
setDesc(text) ;
