Hide/Show UI Macro

Tyler Hoge - Gl
Tera Guru

I cant seem to find a way to Hide/Show a UI macro. Basicly, I want to hide a UI macro next to a field if that field is populated.

 

I tried style="visibility: hidden" which works, but I need it to be based on a condition.

also tried this

 

<a id="email"   onclick="mailTo();">

<img border="0" style="visibility: visible" src="images/icons/email.gifx" title="Send 1st Internal Flash" alt="Send 1st Internal Flash"/>

</a>

<script>

if (gr.u_1st_flash_sent != ""){

var e = gel('${jvar_n}');

e.style.visibility= 'hidden';

}

</script>

 

the condition is: If the field is populated, the ui macro is hidden.

8 REPLIES 8

This is not on a service catalog page. This is on the incident form.


matthew_magee1
Giga Guru

HI Joe-



i too want to do this for our catalog item. I have a variable set:



Container Start


Variable


UI Macro


Container End



The variable above is a simple select box look up


The UI macro is just helpful information that is HTML/CSS formatted



I'd like the user to have the ability to show/hide the ui macro helpful information. some of the helpful info can be wordy unfortunately.



Can you walk me through how you did the show/hide?



Screen shot included of the section i want to show/hide


you can do it.jpg



There is a show/hide icon for the entire variable set but that hides everything; all i want to do is show/hide the test area as shown above



Appreciate it!


edit: that is the label of the container. if you add a label to that container(another variable) you can probably set the name to blank and it wont show "test". If you want another name you can name that label something else. another thing you can do, on any variable you can click the checkbox, "show help". This will give you a new string field that you can select the text



showHelp1.jpgshowHelp2.jpg



I didnt do this for a catalog Item, I did it for incident. it might work on catalog as well. the requirement was, if the fstFlash field is empty, the user clicks the UI macro and it populates the field with a timestamp, and when the field if full, it satisfies the condition and the UI macro is hidden.



Does the variable set all have the same macro that you want to hide? if not, you will have to do this for each element you want to hide.



this is the code that I used that does the hiding.



if(fstFlash != ''){



  var x = document.getElementById("fstEmail").style.visibility="hidden";


  }


  else{


  var x = document.getElementById("fstEmail").style.visibility="visible";


  }




fstFlast is the name of the field I am checking to see if it is blank, you can set this to your condition. (it is a variable and not the actual field.)




var x = document.getElementById("fstEmail").style.visibility="hidden";




this section finds the UI Macro by element ID and sets the visibility to hidden. The element ID in this case is fstEmail. I think you can set the element ID in the UI macro itself.




hope this helps


Hi Joseph-



Thanks for the reply. The Show Help option works great, but....


It does not render HTML unless I deactivate a system property (names escapes me now) and that is a bad thing from what I've read. I'll continue to play around w/ adding a new label and see if I can get it to work that way