Solved

Need to refresh/reload a div after form submission

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
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 look for a specific file type in a local or remote server directory using PHP.

770 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