Forums

Detect which button pressed

lollymaster 13d ago

Hi all,

is there a way to detect during submit section with a php object code(for example) which one of 3 buttons is pressed in the load section? I want to use the return value of php obj in a event switch in submit section.

i tryend something like this:

if (isset($form->data['annulla'])) {   

return 'annulla'; // Se il bottone 'annulla' è stato premuto}

elseif (isset($form->data['next_yes'])) {   

return 'next_yes'; // Se il bottone 'next_yes' è stato premuto}

elseif (isset($form->data['next_no'])) {   

return 'next_no'; // Se il bottone 'next_no' è stato premuto}

else {   

return 'default'; // Default se nessun bottone è stato premuto}

but doesn't works.

Thanks a lot ,

Lorenzo.

Max_admin 12d ago
Answer

Hi Lorenzo

You can give your buttons the same name but set different values for them, then use the

$this->data("button_name")

 in your code, or use the Event Switcher action directly:

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lollymaster 12d ago

Thanks MAX.

But now when i go back the page, the value remain setted.

Is there a way to unset the variable?

As i said i need to use the variable in the event switcher in submit section.

So when i reload the page, the "next_yes" remain setted to 1.

Can you help me?

thanks,

lorenzo.

Max_admin 12d ago

Hi Lorenzo

The solution I proposed sets the value in the HTML element itself, the button "value" attribute, do you need to unset this ?

Your event switcher will be in the "Submit" event of that page as you need, if you go back then the button values stay the same

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lollymaster 12d ago

Yes Max: i need to unset the value. 

Let me describe an use-case:

press the button "nextyes" as a submit button

on submit side i have a php object that return something that i use in a event switcher in the same area(submit).

then reload page

But when i reloaded the page in debug info i saw  that in "data array" the nextyes value is 1.

So i want to unset(or set 0) every time i reload (or load) the page.

Thanks,

Lorenzo.

Max_admin 12d ago

Hi Lorenzo

Could you please post a screenshot of your submit area so that I can understand this better ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lollymaster 12d ago

Thaks Max. 

This is the screen of my submit area:

Thanks,

Lorenzo.

Max_admin 11d ago

Hi Lorenzo

So you can delete or disable the PHP action, change the 3 buttons names to "next", and set the value for each one as I show earlier, the values should be "annulla", "next_no" and "next_yes", then in your Event Switcher use {data:next} in the Switch Value:

Did you try that ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
lollymaster 6d ago

Hi Max,

its sounds better. But im having the same problem that i have already posted in another post: when i reload the page, the variable "next" doesn't reset. So the side effect is that the button pressed is  the "next" with value "nextyes" (for eg.). 

Below a screen after the page is reloaded:

So it seems that i need something that reset all page variables.(i have the same problem for eg. with upload object that after the first usage, the second time shows me the name of the previous upload).

Thanks a lot,

lorenzo.

You need to login to be able to post a reply.