Solved

Need to refresh/reload a div after form submission

Posted on 2012-04-12
5
1,211 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

828 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