This topic is locked
[SOLVED]

Button & Loops - Using Javascript For Multiple Alerts

4/9/2021 4:13:11 PM
PHPRunner General questions
C
copper21 author

Hello All,

Looking for some help. I have a button on the list page. I need this button to go through a list of checked records and then give a status for each of the records checked. My situation is like this:

List Page (Each of these records is checked)

Status, Name
[X] Pending, Brian
[X] Approved, Chris
[X] Not Approved, Pam

My button (Server Event)

while($data = $button->getNextSelectedRecord())
{
$result['Status'] = $data['Status'];

$result['Name'] = $data['Name'];
}

My button (Client After)

???

How do I loop so that I get a javacript alert to state something like "Brian is Pending", and then have a separate alert stating "Chris is Approved", and then "Pam is Not Approved"? I need to cycle through all of the checked records and then give an alert for each.

I can get the alert to work, but it only shows the last person (Pam), and does not alert the first two checked records.

Thank you in advance.

Sergey Kornilov admin 4/9/2021

You cannot go back and forth between PHP and Javascript. You need to finish all the processing in PHP first, prepare a list of messages, pass them to Javascript and display them either one message at the time or all messages together.

C
copper21 author 4/9/2021

Thank you for the clarification. I will try that.