PHP AJAX fields value from previous page - php

I have form in which fields come through AJAX and i fill those fields and send it to next page. When i send it to next page their are two option either edit or submit. When i click on edit button value go to the first page and value display in fields but AJAX field and it's values not appear. How I show AJAX field and it's value in first page?

Related

Fix Input variable in PHP

I have two PHP pages from one I input the year and after submitting year value goes in next page via form input as in image
In next page I have one form input also and after input the values in next page and after clicking compute button the value of year which we call from page one disappear. As shown in image
I want that the variable should not changed which I called from the previous page means the value of that variable should not be change which I called from the previous page.

Gravity Forms - Entering text in a field to also appear in another field without a page reload

How to enter text in one field to then appear in another field without reloading the page.
I have a page with a php form with two text fields and a submit button. When clicking the submit button, a pop-up Gravity Form appears to enter extra details. I need the information entered in the first two php text fields to appear in two text boxes on the Gravity Form pop-up without a reload.
Is this possible? Thanks
Yes, this is possible, but only using JavaScript. These are the steps:
You need to add an event listener to the submit button. E.g. document.querySelector('.class-of-submit').addEventListener('click', function(){ /* code here */ });
Once the event fires, you then need to target the input field(s) that contain the data you wish to access. For example, var enteredText = document.querySelector('.class-name').value.
Then sent the value of the pop-up field(s) like so: document.querySelector('.class-of-target').value = enteredText;
That's pretty much it. You'll want to add way more logic to the above (check elements exists and that the fields are not empty), but hopefully this will get you started.
If you're looking for a codeless solution, check out my Gravity Forms Copy Cat plugin. It allows you to auto-copy the value entered in almost any field to any other field.

Ajax issue while creating PHP pages and Popup window for user input

Actually I have to create one page that is showing all employee information like (name,age,salary,etc) and one add button. If i clicked on add it will open one pop up window which will take user input of (name,age,salary); after submit it will update my database and my first page without refreshing the page.
i have created 3 file.
1) Display.php where i have to display employee information and add button.
2) Add.html i passes this file to popup method on click of add button.
3) Update.php where i wrote database query on action of submit button.
Now i am confused where i should write Ajax ? that will help me to display the record on my first page.
Thanks in advance.
You only need 2:
Display.php in here you display the info and add button, have a seperate <div> that is hidden but shown with anonClick javascript function. In this div you have your submit button which will fire the ajax query.
2.Update.php This will receive the ajax query and return the new data to the first page.
You can put the javascript functions in their own file and call them into display.php if you want.

Preserving data in one form when submitting a second form

I have a page with two forms that is generated with PHP.
The first part contains text boxes, a submit button and a clear button.
The second form is just a button called "Add more text boxes" so the user can add more to his form if he needs to.
The problem is when I click the "Add more rows" which loads another page which changes a value.
This value then affects the original page when it reloads causing more text boxes to get created.
The problem is that I lose all the data that was entered.
Is there any way to preserve the data when the user clicks "Add more rows"?.
Here's a screenshot of my page.
Thanks
If you want to do it without js than you put all in one form. When you click button to add row all entered data will be available in $_POST or $_GET so you can fill form with existing data and add a row when generating new page.
Ideally you should use javascript to dynamically add new rows w/out making new requests to the server and loading new pages. But if you want to keep it javascript free. If it's all the same php script just controlled by conditions, just use the $_POST['variable'] values as the value="$_POST['variable']" in your fields. If it's handled through multiple scripts, you can use a session variable to pass the data from one page to the next.

Implementing a preview button for a form and keeping the form data after clicking the button

I have a form with a wysiwyg editor and I would like to add a preview button so the user can see how the content would look like in the website.
In order to do this I inserted another submit button wich gets the info from the form and redirects to a preview page.
All ok, but after clicking that button the form content disappears so the user can see a preview but it has no data in the actual form in order to make some changes or to submit the form in order to save the data.
So here's my question: can I have this preview button and also keep the data in the form after clicking the preview button?
What you need is either:
Repopulate the form from the preview function (that means manually fill in the form with the submitted data)
OR
Use Ajax to submit the form to the preview function and keep open the current edition page.
By the way, you can't have two submit for one form.

Categories