The CreatorCon Call for Content is officially open! Get started here.

how to dynamically change service catalog's description and picture

hemanhmchan
Kilo Explorer

Is there any way to change the description and picture when select from a "Select Box"? Thanks.

1 ACCEPTED SOLUTION

Bhavesh Jain1
Giga Guru

I can give you an idea on how you can do this.


Write an onchange client script on your select box field.


Script:



// Get all the images of your document


var image =document.images;


image[<position where your current image is>].src = <URL of your new image>;



 
//Lets say I want to replace the below iphone image to attachment clip icon.



var image =document.images;


alert(image[3].src);


image[4].src = 'https://demo010.service-now.com/images/icons/attachment.gifx';




  Before script:


Capture 2.png




      After script


Capture 2.png:






You can use similar logic to change description also. Let me know if you have queries.



How to find the position of your image?


Answer: You can give few alerts to check your image position.


View solution in original post

6 REPLIES 6

Hi bhaveshumour, thanks.



I got something similar and am able to change the description now. Thanks for your prompt reply.



var ele_Parent = document.getElementsByClassName('catalog_description')[0];
var div = document.createElement('div');
div.innerHTML = 'something';
ele_Parent.insertBefore(div, ele_Child.nextSibling);

Excellent