Question about the best way to change picture control src from another field value

  • 11 March 2019
  • 2 replies
  • 3 views

Badge +1

Hello from France

My environnement : SharePoint 2013 Standard On Premise with Nintex Forms & WorkFlow 2013.

My question :

I try to use a picture control to display a logo company in a Nintex Form.

The src attribute for this picture is something like "http://monsharepoint/picture/<Company>.jpg"

where <Company> is a variable.

I have a field name "Company" in my Form where the user can input the company name.

I want to set the src attribute for my picture control to display the correct logo company when the user input n new company name.

I can't affect a javascript id to the picture control. So I don't know how to access the src attribute to update it when the text field with the company name change.

Can someone help me to display and update a picture on a Nintex Form with the ability to update the displayed image when an event on a textbox or a combo box can change the src attribute for this picture control ?

Thank you.


2 replies

Badge +7

I haven't tested this, but what about using a CSS class instead of the Client ID JavaScript variable? Then you could use jQuery to interact with it:

NWF$('.myImage').attr('href','someURL');

You may need to tweak that a bit, but it should get you started in the right direction.

Badge +1

Hello @chaddavis 

With your help I found a way to do what I want.

I affect a CSS Class "logoCompany" to my picture object.

And by javascript code I update the "content: url" property with a variable.

My solution :

NWF$(document).ready(function()
{
NWF$('#'+idCompany).change(function()
{
var societe = NWF$(this).val();
var sqlField = NWF$('#'+idSqlCompany);
sqlField.val(societe);
sqlField.parent().find('select').val(societe);
NWF.FormFiller.Functions.ProcessOnChange(sqlField);
});
NWF$('#'+idSqlCompany).change(function()
{
var societe = NWF$('#'+idSqlCompany).parent().find('select').val();
var imgCompany='url(/images/companies/150x150/' + societe + '.png)';
NWF$('.logoCompany').css({content:imgCompany});
});
});

 

Thank you for your help.

Reply