This topic is locked
[SOLVED]

 Get field values of 'checked' row

9/25/2018 7:20:39 AM
PHPRunner General questions
C
ChrisOmn author

Hi all
In PHPR10 list page I wish to get the field values of a row that have a 'selected' checkbox.
I've exhausted my Javascript experience (+ examples I find in this forum + other Javascript forums).
Please help me on how to do this?
--------------
I see these examples:
1) Get all checkbox values but I've no understanding how to get the associated 'data-record-id' for the row.

var selected = new Array();

$("input[name='selection[]']:checked").each(function() {

selected.push($(this).attr('value'));

});
2) Access each record's field values and then control of the record's associated checkbox:

var recsId = pageObj.inlineEdit.getRecsId();

for (i in recsId) {

if (Number($("span[id='edit"+recsId[i]+"Horsepower']").html())>200)

$("input[name='selection[]'][id='check1
"+recsId[i]+"']").attr('checked','checked');

}
I guess I need to:

  • traverse 'selection[]' array to retrieve each entries parent 'data-record-id',
  • find all 'span class' with same 'data-record-id' value,
  • retrieve 'val' for that 'span'.
    Thanks for any advice.

C
ChrisOmn author 9/25/2018

Solved.

To help others:
var selected_rows = new Array();

var array_len = 0;

var text = "";

// ---------------------------------------------------------------------------
// capture record IDs of selected rows

$("input[name='selection[]']:checked").each(function()

{

selected_rows.push($(this).parent().parent().attr('data-record-id'));

});
array_len = selected_rows.length;

alert(selected_rows);
// cycle array of record IDs and insert value into element name to reference value

for (i = 0; i < array_len; i++)

{

// display element value

alert("Status value: " ("span[id='YOUR COLUMN NAME"+selected_rows[i]+"YOUR COLUMN NAME']").html());
find your column name in browser by inspecting element - likely element name includes data-record-id number - e.g.: <span id="_status[/b]"
// if element value = Active, continue processing..

if ($("span[id='edit"+selected_rows[i]+"_status']").html()== 'Active')

{

alert("record id:" + selected_rows[i] + " has status Active");

}

}

admin 9/25/2018

This is what you normally need to do:

https://xlinesoft.com/phprunner/docs/button_getnextselectedrecord.htm
And if you need to access those values in Javascript I still recommend to use getNextSelectedRecord function, prepare an array with data and send it to ClientAfter event.