Change Image Source on Button Click

  • 30 August 2019
  • 1 reply
  • 5 views

Badge +1

Hi,

 

I've been asked to build a form that includes a 7 x 3 gride of status icons.  For this fairly heavy grid, my ideal case would be that each icon in the grid is a button that can be clicked, and that doing so cycles that icon through red, amber, green statuses.

 

I'm familar with using buttons to trigger javascript functions.  My question is, how can I access the button properties with my javascript function to update the image src url?  The three status icon urls can be hardcoded, so it's just a matter of iterating over those urls on click.  

 

Many thanks!


1 reply

Userlevel 6
Badge +22

Hi,

I'm not the greatest at JavaScript but I looked at this post anyway.

I could probably make the traffic light but the issue would be making the settings save. 

Not sure how you could save all the settings so that the form could be viewed and updated etc.

If I was to do this I would use a choice control and use formatting rules to change the backgrtound color based on the choice.

 

4222i29CA3AE553D0BF46.gif

This handles the change of colour and the chosen choice is saved to the SharePoint list.

 

Reply