load form at the same page without refreshing - php

I have the beneath page and when i need to enter another education background so i enter it in a html base.
http://i.stack.imgur.com/6mnA7.jpg
As i am newbie in PHP so i need help in this regard.
I wanted to ask that is there a way to make it dynamic i mean when i click on that plus sign then a form form should come the first row without refreshing the page and by clicking on submit button it should save to database and come to the first row.
Like stackoverflow.com comment section.

You would need to use preventdefault on the event object.
Please check here for further clarification..

Related

Setting cookie through PHP when Contact Form 7 submited

I'm working on a landing page made with Bootstrap 4, Wordpress and Contact Form 7 plugin. In the page I have 4 buttons that when clicked show the same Contact Form 7 pop up form. I want them to:
Any of the 4 buttons clicked for the 1st time show the pop up with the form (already done).
When the form submited and any of the buttons clicked again (could be the same one) do not show the form, but start a download of PDF document.
I don't know how to design that better. I think that when the form is submited a cookie is set through PHP so I can check in each button if the form is done. Is it a good aproach? How should I set the cookie? Is there any other way?
The simple solution would be redirecting the user to the PDF right after the form submission - there is a simple guide on how yo can do it. That could enchance the UX, users wouldn't need to understand that they need to click the same button once again.
Also, it could be easier because you would obviously want to change something after the actual event of sending the data (no matter how you track it). For example, you will not only need to add teh URL to the PDF into the button, but change the text and maybe even the style of it to make it obvious to the user.
However if you'd like to make it complex way - you can try changing the link on the button of form submission or adding the download link (or "enabling" it), while disabling the submission button inside your form. Some examples on changing the link or showing/hiding contect can be found here and here - all using the jQuery, no extra PHP needed.

How do I redirect to different php files depending on what button is pressed in the base php file?

I have a base php file that displays items in a database on an html table. Each row has a remove button. When pressed, it will remove that one item from the database. At the end of the table, there is an add button that once it is pressed will take you to another php file with a form that you can fill out with information to add to the database. I am having two problems. The first is that I am not sure how to determine what remove button is pushed. My second question is how do I move to a different page for the other php file once the add button is clicked? I am not supposed to use AJAX for this. And though I tried using include and isset, I couldn't get them to work properly. Any help, conceptual or code examples would be greatly appreciated.
If you can go to other pages, simply create a form with a hidden input field holding the id of the row and have the remove button be a form submit button.
On the remove button being clicked it will go to the delete php file and redirect back to the table page.
As far as the adding button, instead of using a button just use a link to the add form.
If any of this doesn't work because of requirements you haven't mentioned let me know of any restrictions you have.
For your first problem, just make a form for each individual row of data. that way, you will be able to pass by post the relevant id you want to remove.
Another way would be to create a "button" (not a submit button) and have the relevant onClick="..." script - like redirect to "index?Action=Remove&Id=xxxx"
By making different form for each button, you add button will have its own "action" in the form and you'll be allright!
You either have to generate a new "form" (with proper html) if you need to pass data to your next page. If you only need to redirect depending on which button you press, you can have a onClick="..." event on your button. Make sure not to make a "submit" button :)

display data from database, edit it, but when click on previous page, the data gone.

i got 4 pages which are company details, job requirements, job responsibilities and design. so im gonna update the data from these pages. so i retrieve the data from database to be display into form for these 4 pages. after i edit the values on first page, then i go to next page for next update. but when i go back to previous page, the data wont keep the edited value but display the old data that i retrieved from database. so how to prevent this to happen ? same goes if i refresh the pages. i know i can use the session to store edited value but still i think that form will display the old data. help me give the idea how to do this pls ! thanks
You need to follow below steps
Go to next page by submit & action attribute
In next page hold all the post value into hidden fields
Use a back button to go back.
when go button will be pressed submit the form which is holding the hidden fields
Now you are in first page and simply use $_REQUEST or $_POST to get the previous value.
Hope you under stand.
N.B: If you use browser back button browser will ask you to confirm to resubmit the form. If you confirm then no problem but if you didn't confirm then you lost your values.

How to resubmit PHP form with javascript

I am wondering if it is possible to to resubmit a form with a button click that calls up a javascript command.
So this is basically what I'm trying to do -
page 1: form; action = page2.php
page 2: generate a randomized list according to parameters set by page 1
I would like to place a button on page 2 so that on click, it would be as if the user has hit F5, and a new list would be generated with the same parameters.
I found a lot of help on Google with people trying NOT to get this to happen, but I'm not sure how to actually get it to happen.....
Thank you!
You could use location.reload(true); to refresh the page.
<button onclick="location.reload(true);">refresh</button>
you only need to use. location.reload() instead of location.reload(true). since this will not disable caching for the reload but using true as the parameter will.
here is the reference. How to refresh a page in jquery?
EDIT: why not just use hidden input field and preserve the values and fetch it anytime you want to?

How do I make the iframe(child) from another iframe(parent) bigger than the its parent?

I'm creating a Purchase Order form in PHP and Fancybox and I'm having a hard time making a UI wherein inside a page the user can select a supplier and then after that a hyperlink will appear that will allow the user to add an item and once clicked another modal window is shown where a form containing the list of items are displayed as well as the quantity.
I was already able to do all the php coding correctly my problem now is that once I open the first Iframe the second Iframe becomes very small(which is what is expected because of the script 'width' and 'height'). Is there a way to work around this?
I already know how to get back to the previous iframe, I did that by adding a submit button with a form action="mypage".
Sir/Ma'am your answers would be of great help. Thank you.

Categories