This topic is locked
[SOLVED]

 Javascript to update list page field on specific row

12/9/2016 7:12:45 PM
PHPRunner General questions
H
headingwest author

Hi, for a list page with a shopping cart I have + / - buttons for each row. I also have qty display value.
I want to access the quantity field on a button row and use getElementById("database_row_id") or to change the displayed value and update that row without refreshing.
How can I identify that row "id"? They seem to start at 4. eg: <span id="edit4_quantity">6</span> is the first row. I want to match it to the databaseid or get that "4" in the button events.
I've tried inserting a code snippet to achieve <span id="databaseid"></span> but snippets can't access $pageObject->getCurrentRecord() to insert the item id for each row.
I've tried editing the html to add <SPAN ID="{$ID_value}"></SPAN> but the {$ID_value} includes it's own SPAN "ID", it inserts more than the value.
Any ideas? Thanks.

H
headingwest author 12/9/2016

OK, if anyone needs to do this...
With your ID field, view as "Custom", insert a meaningful SPAN ID eg:

$value='<SPAN ID="' . $data["ID"] . '">'.$data["quantity"].'</SPAN>';


With your button for that row, SERVER, get the database value and database ID, pass through to Client After:

$result["records"] = DBLookup(" select quantity from shopshopping_cart where ID = ". $data["ID"]);

$result["spanid"] = $data["ID"];


Then in Client After for that button:

var qty = document.getElementById(result["spanid"]).innerHTML;

qty++;

document.getElementById(result["spanid"]).innerHTML = qty;