Dynamically get image into the page

kavyahv
Kilo Contributor

Hi Everyone,

Im unable to   get the image dynamically onto the page.How can I do it in servcienow?

your suggestions will be helful

Regards,

1 ACCEPTED SOLUTION

Hi Kavya,



see below example..


i have one field of type of Image in one table.


find_real_file.png




now i want to display those images to the dynamic block.



so i have added a dynamic block to one page. and wrote below content.


<g:evaluate>    
  var images=[];
var gr = new GlideRecord('x_11777_crappy_app_crappy_appppp_table');  
gr.query();  
while(gr.next()){

images.push(gr.photo.getDisplayValue());


}

      </g:evaluate>  


   


      <j:forEach items="${images}" var="jvar_color">  


              <g:breakpoint/>  


              <img id="${jvar_color}" src="${jvar_color}"></img>


      </j:forEach>



so it will display images like shown below. and they will have different Id so u can use Jquery and reference them in your script.



Capture.JPG



Let me know if u have Questions.




(please mark helpful/correct/like if it helps)




Regards,


Rushit Patel


View solution in original post

8 REPLIES 8

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Could you give us some more info on what "page" you're trying to get an image into and what the source of the image is?


Hi Brad,



I am trying to add a image to dynamic block   to a page and on click of the image the details are getting displayed.



Now I want to dynamically get the image from database. I have written a Jquery script to display the details on click of the image and this is using the id.


Since I have many images could you please help me how can I dynamically get the image from database.



Regards,


kavya


coryseering
ServiceNow Employee
ServiceNow Employee

Hi Kavya,



Can you provide more information? At a minimum, we need answers to the following questions to begin to offer suggestions:



What page are you trying to add an image to?


How are you trying to add the image?


Where does the image come from?


What makes it dynamic- are you trying to add it based on user input?


What have you tried already?


What does your code currently look like?



Thanks


Cory


Hi Cory,



I am trying to add a image to dynamic block   to a page and on click of the image the details are getting displayed.



Now I want to dynamically get the image from database. I have written a Jquery script to display the details on click of the image and this is using the id.


Since I have many images could you please help me how can I dynamically get the image from database.



Regards,


Kavya