Missing value

Discussions about Cross-site Lookup
Locked
User avatar
NatašaCerin
Posts: 7
Joined: Mon May 01, 2017

16 May 2017

Hi
I'm checking if some of the fields in the choice menu are selected and if nu. xx or xx is selected then is obligatory to fill lookup field.
The check is working, but if you open the edit form - the value in look up field is not visible.
The code is on Save button. Without the code the value is visible - so I think that is something wrong with the code.
Can you chek it? Thanks

var inp = document.getElementsByClassName("ChiiceField")(0).getElementsByClassName("fd_control")(0).getElementsByTagName("input");
var result = [];
for(var i = 0; i < inp.length ; i++)
{
if(inp(i).checked)
{
result.push("x" + i);
var ReIzbrani = (((document.getElementById(cslLookUpField)).getElementsByClassName("select2-choice")(0)).getElementsByTagName('span')(0)).innerHTML;
if(i==8 || i==12 || i==13 || i==14){

if (ReIzbrani == " "){
alert( "Missing Lookup Field");
return false;
}
}

}
};
if(result.length == 0)
{
alert( "one of field has to be check!");
return false;
};

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

16 May 2017

Hi,

I noticed a misprint here:

Code: Select all

getElementsByClassName("ChiiceField")
should be:

Code: Select all

getElementsByClassName("ChoiceField")
Most likely, you have a syntax error in the code, that's why the lookup field is not populated. Please, check the browser console (F12).

Also, I'd recommend you to use Forms Designer JS-framework instead of the plain JavaScript. Please, read our posts:
https://spform.com/javascript-framework ... ynamically
https://spform.com/javascript-framework ... point-2010
https://spform.com/javascript-framework ... eld-values

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests