Updating value of one field on change of value of other field - php

I am using a Joomla form add-on.
the form already captures logged-in user-name on submit.
Now I want to create two fields
verified- a button field, which allows me to add javascript code for the button.
Verified by - (it can be a calc field type, where I can use both Javascript and PHP)
Every time the button verified is clicked, the verified by field captures the logged in user's name, if the button is clicked second time by another user, it adds the name of that second user in the verified by field, not overwrite it.

Your question isn't very clear, but from the sound of the question's title you might want to check out MySQL triggers.

Related

Fetching value from codeigniter form field among input fields of same name

I don't need any code, I just need the right way to do it.
What I am doing?
Here is the thing. I am making a software for a pharmacy (Drug Store). I have created a tab for shortlist for the drug. See the picture.
enter image description here
What problem I am facing?
In the last column, I have a form field to input drug or add stock. But you can see there are many form fields for so many rows. When I click to "Confirm" button, it's not gonna work cause the table has been generated using loop. So, for all the fields there are same name.
How can I take the value of input field right above the submit button. I mean when I click confirm button it will take same row's input field not others.
How can I do it? No code needed. I am using php codeigniter framework.
Thanks
create one variable like '$i' and increase it and append it on last of input name.as well as give id to submit button and append id with $i.
for eg. name_1,name_2,submit_2,submit_2
when you submit just get the id of submit button. Then get the number from id eg.2,3.take input from the same input variable id. You can do it using ajax. So it will be done without refresh page.

How to use PHP/jQuery to realize a unique user on load?

I have a webpage that stores the user ID of someone who clicks a button on the page. Once the button is clicked, that user needs to be able to see content (just another button) that only that user can see. Other users on that page won't be able to see that button.
The problem I'm having is I don't know how to use that unique user ID, which is superglobal, to recognize on load what the user ID is, and how to execute if its the correct user, show the otherwise hidden inputs.
It is same problem that arised to me
You have two option to solve this problem
use a PHP globals like $_COOKIE[] or $_SESSION{]; To store the id of that user
or you can use a database field of array type.It will store the value of button clicked by a particular user(using a database will more efficient because you can use it any time and it do not expires )

Submit button and form handler from Grocery CRUD table view?

I have an app that has to send bulk email to selected users. I need to display my users table with a checkbox per row and a submit button with a form handler to operate on checked rows. Considering the built-in features of GC like the filter and column sorting, pagination, etc... I thought using GC would be a good solution. I found info on adding the checkbox. How do I add a submit button and form handler? Anyone have a hint or two where to start?
There are several ways to do this. I will explain two ways here.
Create the checkbox, for the id value use some unique data of the user details such as userid or username. After that on change of check box selection call a javascript method to update the hidden field with the current status. You can use some special delimiter to separate the check boxes. Let say if check box with id 1,5,6 are checked then the hidden field should be updated to "1#5#6". In the server side you can use the explode method to make an array and then you will have the usernames in array.
Another way is using AJAX and processing it immediately. I have used this way on my Codeigniter Code Generator at http://www.thephpcode.com to update the user roles' permissions. An admin user can grant or revoke permissions to a user role. All the permissions will be displayed with check box and with current status. When changed it will be updated immediatly through AJAX call.

PHP_Calculator_Code

I have a project where I am going to create a calculator using PHP. I have done all the basic arithmet ic operation and it is operating well. My only problem is that, if the user for example had already entered numbers and he/she chose to add it, and after that, if the user would want again to enter another input, the previous answer should be erased and the newly entered input should have an empty space first. Here's our code:
Use javascript - when any of the buttons are pressed, clear the input field.
If you MUST use PHP, just set the input's value to value='', so when the page reloads, it's empty.

'Previous' Button in HTML/PHP

I thought hours about that problem but I didn't come to any conclusion. My problem here is that I need a 'Previous' Button added to a form. The user should fill out a formular that is splitted up in 13 parts. Every part is an own formular having a 'Next' button for submitting everything to a database and redirecting to the next page.
How do I integrate a 'Previous' button there? ...
I don't if it might be usefull for you to know that I'm using cakePHP, and well I'm pretty new to it.
Store the POST data of each form and the current form index in your session.
When clicking the back button, open form (currentForm - 1) (if that's a valid form index) and populate the fields with formData[currentForm] (assuming currentForm is now the form the back button redirected to)
The question really is, do you want to store each stage of the formula in a record? or do you want to store every stage of the formula in the "transaction"? The difference here is important. What is your relationship with the user? Do they login? are they anonymous? How do you associate their answers from one form entry to the next? If you store each entry in the database, in some chronological way, then simply populate the previous form with the previously entered values; when they click previous. If you do not store the entries and instead utilize a session to retain values between "next" clicks then populate the "previous" form with those values.
I've coded a similar form in classical ASP, see if you can make it work in CakePHP:
I had a 7 step form, step 2-7 have previous buttons. Each step consists of one asp script. All scripts post back to themself. I check the REQUEST_METHOD upon every invocation of the script to see if it was called by GET method or POST. If POST then data is validated, if validated then it is saved. There are three submit buttons on forms that allows user to choose whether he wants to just save the data, save and move to next step or save and move to previous step. Depending on which button was clicked, the user is "redirected" to the previous/next page. This post specifies how to add and handle the previous/next buttons:
Multiple Submit Buttons — Specifying default button

Categories