Help with finding an old post

Hi! I need help finding an old post from around 2018 or 2019. It was in a Dashboard thread. It was a brilliant piece of code, I think the authors name was Bill, but I’m not 100% sure. It contained code for getting text from a data table and sending it to text fields.

The panel had a data table with 3 fields Number, Player and Jersey. It then had a drop down list that contained the data from the table formatted like this:
1 - Brian Yankees when you selected from the drop down, the same data would appear in 3 separate text fields of the same data.
You could edit the text in the table. You could also add a row, delete a row using buttons. One last button would update the drop down.

I hope I’m making sense here. I had downloaded the panel/code and it has worked beautifully for me. I was also able to go into the code and modify it for whatever I needed it for. I had 5 different versions of it.

The server where this data was stored crashed and all my custom panels got wiped out. I now have to create everything from scratch and this particular panel/code was pretty much the center of all the panels.

Thanks in advance for your help

Well… I dont know where that old post is.
But I have posted similar posts (or maybe on the same post for that matter) about the same matter some time ago.

I use the same method in alot of tables on my own projects, and figured I could allways use some freshening up on my skills.
So here you go!

true --- 1 - Player 1 2 - Player 2 3 - Player 3 tableIndex var x = params.getElementCount('tableInfo');

var newPlayer = {
num: ‘’,
player: ‘’,
jersey: ‘’
}

params.setValue(‘tableInfo’, x, newPlayer);


var i = params.getValue(‘tableIndex’, 0);
var x = params.getElementCount(‘tableInfo’);
if (x > 1) {
params.getParam(‘tableInfo’, i).remove();
params.setValue(‘tableIndex’, 0, i-1);
} else {
var newPlayer = {
“num”: “”,
“player”: “”,
“jersey”: “”,
};

params.setValue(‘tableInfo’, 0, newPlayer);
params.setValue(‘tableIndex’, 0, 0);
}


var players = [‘—’];
var x = params.getElementCount(‘tableInfo’);
for (var i = 0; i < x; i++) {
var player = params.getValue(‘tableInfo.’ + i + ‘.num’, 0) + ’ - ’ + params.getValue(‘tableInfo.’ + i + ‘.player’, 0);
players.push(player);
}

var x = players.length;
var cArray = ;
for (var i = 0; i < x; i++) {
cArray.push({key:i,value:players[i]});
}
var choiceConstraint = params.createIntChoiceConstraint(cArray);
params.replaceConstraint(‘playersDropdown’, choiceConstraint);
params.setValue(‘playersDropdown’, 0, 0);

var sel = params.getValueAsString('playersDropdown', 0); var num = ''; var player = ''; var jersey = '';

if(sel != ‘—’) {
var check = sel.substr(0,sel.indexOf(’ '));

var x = params.getElementCount(‘tableInfo’);
for (var i = 0; i < x; i++) {
if(params.getValue(‘tableInfo.’ + i + ‘.num’, 0) == check) {
num = params.getValue(‘tableInfo.’ + i + ‘.num’, 0);
player = params.getValue(‘tableInfo.’ + i + ‘.player’, 0);
jersey = params.getValue(‘tableInfo.’ + i + ‘.jersey’, 0);
break;
}
}
}

params.setValue(‘playerNum’, 0, num);
params.setValue(‘playerPlayer’, 0, player);
params.setValue(‘playerJersey’, 0, jersey);

That should do the trick if I didnt misunderstand you.

Warning: It does require that the # (number) field is unique, as the selection in the dropdown will choose the first occurance of the number in the dropdown.

​

Thank you so much Aleksander! This is perfect and works just the way the older version worked. You don’t know how much extra work you saved me! Thank you again!