views:

87

answers:

3

Here is my main page code:

        <form><iframe name="iframe_pic" src="iframe.html"></iframe></form>

Here is my iframe.html:

    <script type="text/javascript">
function reset_imageform(){
    f = document.getElementById("pic_form");
    f.src=f.src;
}
</script>
</head>
<body><form name="pic_form" id="pic_form" enctype="multipart/form-data" method="post" action="bincgi/imageUpload.php"><input name="pic_file" type="file" id="pic_file" size="35" onChange="this.form.submit();"></form>

and here is some of my php file imageUpload.php:

    $display_image="<img src='../temp_images/$newfilename'>";
$display_image.="<br><a style='font-weight:bold; font-size:12px;' href='#' onclick='window.parent.reset_imageform();'>remove picture</a>";
echo $display_image;

READ: As you can see I am trying to call javascript inside iframe.html to reset the form. This is because after all my php, the image shows, and I want the user to be able to click a link and then the form gets resetted and the user can chose another picture to upload.

Should I reset the form (pic_form) or should i reload the entire iframe (iframe_pic) that contains the 'pic_form'? And any code would be appreciated on how to do this, if anybody knows?

Thanks

A: 

It looks to me like you're trying to reload the form when in fact you should reload the actual iframe.

Andrei Serdeliuc
how can i reload the iframe then?
Camran
Since you are in the iframe, you should be able to run: document.location = document.location;
Andrei Serdeliuc
actually that doesnt work, the popup comes up that always asks if i want to send the information again in the form, then even if i do, the form isnt resetted, the image is still there that was uploaded... sigh
Camran
+1  A: 

How about using the form's reset button?

<input type="reset" value="this button resets the form" />
David Thomas
Goodness, what are we stupid. Overlooking the simple things, eh? ;)
Franz
Maybe I'm just too simple to see past the simple things? Swings and roundabouts... =)
David Thomas
+1  A: 

Here is how you can reload an iframe:

var iframe = document.getElementById(yourframe);
iframe.contentDocument.location.reload(true);
Franz