Auto-numbering of multiple selectbox values on list page?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
accora
User
Posts: 46

Auto-numbering of multiple selectbox values on list page?

Post by accora »

I use PhpMaker v2017.0.7, and have managed to sort values in new lines with this code in row_rendered event, after updating ew_ViewOptionSeparator to "---" in phpfn13.php:
}

if (CurrentPageID() == "list" && $this->files->CurrentValue != "") {
$this->files->ViewValue = str_replace("---", "<br />", $this->files->ViewValue);
}

The result is:
P09-01-01, Rev 07, Backrest
P09-02-01, Rev 04, Wing Left
P09-02-02, Rev 04, Wing Right
P09-03-01, Rev 03, Seat Box
P09-04-01, Rev 11, Side Piece, Left

Any tips how to auto-number lines of multiple selectbox values like this?
1) P09-01-01, Rev 07, Backrest
2) P09-02-01, Rev 04, Wing Left
3) P09-02-02, Rev 04, Wing Right
4) P09-03-01, Rev 03, Seat Box
5) P09-04-01, Rev 11, Side Piece, Left

Cheerio!

Marco


sangnandar
User
Posts: 980

Post by sangnandar »

You might do this.

These are the generated elements for the list values (they already have incremental id):
<label><input ... id="x(fieldname)[]0" ... >"Text"</label>
<label><input ... id="x(fieldname)[]1" ... >"Text"</label>
<label><input ... id="x(fieldname)[]2" ... >"Text"</label>

You can copy this incremental id and put it before "Text".

  1. Use jQuery .attr() to get id value. // output: x(fieldname)[]0
  2. Do string operation to get only the number. // output: 0
  3. Then add by 1. // output: 1
  4. Use .innerText() to update "Text". // output "1) Text"

Good luck.


Post Reply