Solved

Need to refresh/reload a div after form submission

Posted on 2012-04-12
5
1,115 Views
Last Modified: 2012-04-16
Hi,

I thought this was a extremely simple question, but ik can't find the answer...
After my php form is submitted, it echoes: "form submitted"

When this message shows, i would a specific div to de reloaded / refreshed. because it contains a picture that could be renewed by the form.

How can i make this specific div refresh?

Thanks
0
Comment
Question by:peps03
5 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37838476
>After my php form is submitted, it echoes: "form submitted"

what about :

After my php form is submitted, it echoes: "form submitted<div style='display:none'><img src='images/'" . $img_fullpath . "' /></div>"

echo "form submitted<div id='myimage' style='display:none'><img src='images/'" . $img_fullpath . "' /></div>";

Open in new window


to show it :

to refresh your div :

document.getElementById("your_div_ID").innerHTML = document.getElementById("myimage").innerHTML;

Open in new window

0
 
LVL 20

Expert Comment

by:Proculopsis
ID: 37838482
You need to use an ajax post, as in this jsfiddle.

    $.ajax({
        url: "/echo/html/",
        data: data,
        type: "POST",
        success: success
    });



function success(response) {
    $("#result").text("Form returned: " + response);
}

Open in new window

0
 
LVL 19

Expert Comment

by:Bardobrave
ID: 37838514
Strange... how do you submit your form without losing focus on the page? Do you use an AJAX call to make the submission and load the message when it's returned?

What's the content on the div and how do you load it on the normal flow of the page?
0
 
LVL 8

Expert Comment

by:X-treem
ID: 37838580
if you are using (i)frames you can echo a javascript to change the source of a picture instead of just "form submitted"
if using ajax, you can do this as well, but you need to parse the result (to execute the javascript)
0
 

Author Closing Comment

by:peps03
ID: 37850723
Works great leakim971!!!
Thanks again!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now