This topic is locked
[SOLVED]

 Access a field in list

5/19/2011 11:29:52 PM
PHPRunner General questions
R
rooster27 author

I want to be able to get/set the value of a specific field in a list.
The following is supposed to work, but probably only works for the first record in the list:

var ctrl = Runner.getControl(pageid, 'FieldName');

ctrl.on('click', function(e){

alert(ctrl.getValue());

});
Is there perhaps a way to access a field in any row?

var value = event.target.value

should work, but for one or other reason javascript does not accept

this in phprunner. Any ideas?

Sergey Kornilov admin 5/20/2011

I guess a bit of clarification is required.
Are you talking about inline edit mode or about something else? What you trying to achieve?

R
rooster27 author 5/20/2011



I guess a bit of clarification is required.
Are you talking about inline edit mode or about something else? What you trying to achieve?


Yes, inline edit mode - I want to interactively increment a field by clicking on another field,

using javascript.

Sergey Kornilov admin 5/20/2011

I see what you mean.
If both fields belong to the same record you can use Javascript API. Make sure you add your code to Edit page Javascript OnLoad event. It will work in both regular and inline mode.

R
rooster27 author 5/20/2011



I see what you mean.
If both fields belong to the same record you can use Javascript API. Make sure you add your code to Edit page Javascript OnLoad event. It will work in both regular and inline mode.


Can you perhaps help with an example?

I cannot figure out how to access a specific row with Javascript.
If I use:

var ctrl = Runner.getControl(pageid, 'FieldName');

Does PHPRunner know on which row you are?
To be honest, I could not get above code to work, and am using:

var recCtrlsArr = Runner.controls.ControlManager.getAt('TableName');

var ctrl = recCtrlsArr[i]; (as a workaround - where i is the position in the field array)

And then:

ctrl.getValue() to fetch the value.

Sergey Kornilov admin 5/20/2011

You won't be able to access specific row. This solution will only work if both fields belong to the same record (row).
That's why I'm asking to provided as detailed as possible explanation. Give us more details.