Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Bhavesh Jain1
Giga Guru

yes you can write an onchange client script and do that. Let me check if I can write the code for you.


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.


Hi bhaveshumour, it works. Really thanks to that. Sorry, but what is the object component   of description, is it document.description? Thanks. Heman


I can give you a hint but you might need to dig in more.



Try this script:


var desc = document.getElementsByClassName("catalog_description");


alert(desc[0].innerHTML);