How to get checkbox value?

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

How to get checkbox value?

Post by WABez »

I'm using PHPMaker 2024.10. I have a checkbox on a form that I want to use the value to redirect a user to a different page if the checkbox is checked/unchecked.

My dumb question!
Server side:
Server Events > Global > Table Specific > Common > Row_Inserted I used the $this->terminate("mypage"); and it is working fine. Now for the checkbox value, to redirect the user to this page or not.
How can I evaluate whether the checkbox is checked or not?


arbei
User
Posts: 9456

Post by arbei »

It depends on how you add the checkbox. Is it one of the fields? In general, you can get it from $_POST["MyCheckboxName"].


WABez
User
Posts: 202

Post by WABez »

Thanks, yes it is one of the fields.

I have tried with:
if (isset($_POST["MyCheckboxName"]))
but no luck.


WABez
User
Posts: 202

Post by WABez »

Solved, error in the code.


mobhar
User
Posts: 11779

Post by mobhar »

If you are using Row_Inserted server event, then you may try: $rsnew["YourFieldName"] (change YourFieldName to your actual field name).


daveb
User
Posts: 35

Post by daveb »

How do you use this in selection criteria? Current selection shows field_name contains but a value can not be entered?


arbei
User
Posts: 9456

Post by arbei »

You need to check if row type is RowType::SEARCH, also see PHP Enumerations.


daveb
User
Posts: 35

Post by daveb »

I have a field defined as "Activated" varchar(1) and it is set up as a checkbox with Y or N, When I specify as part of the search options I get an entry "Activated contains " followed by a checkbox which I can click on to see a checkmark. However, it does not affect the search as all records are selected whether the checkmark is on or off.


arbei
User
Posts: 9456

Post by arbei »

If it is a boolean field, make sure you use enum(Y/N) (assume you use MySQL) otherwise it will be considered as varchar field, and you should not enable Text input for search under the Lookup Table panel. Also make sure the search operators under Advanced Search is not set as "LIKE".


Post Reply