Johny
Johny

Reputation: 175

Pop onload not working

I have a popup submit form that once i submit it should load a popup window into my current window using the window.load method. The problem is that i always get redirected to that window(imagine_decupare.php) ,not getting that window to load as a popup in my current window. Any ideas as to why?

function hide_popup(id){
            if (document.getElementById){
                obj = document.getElementById(id);
                if (obj.style.display == ""){
                        obj.style.display = "none";
                }
            }
    }

    function poponload(){
            testwindow = window.open("decupare_imagine.php","mywindow","location=0,status=1,scrollbars=1,width=100,height=100");
            testwindow.moveTo(0, 0);
        }

    <form action="decupare_imagine.php" method="post" >
                                                        <input type="text" name="alt-rol" value="<?php echo $data[1];?>" style="display:none;" /> 

                                                        <a href="javascript:hide_popup('my_popup<?=$data[1]?>')"  style="width:5%;float:left;margin: 0 0 0 90%"><img src="../images/icon_error.gif"> </a>
                                                        <div class="radio_pop">
                                                        //some data to be sent      
                                                        </div>
                                                        <input type="submit" value="Tip imagine" class="buton_imagine" onclick="javascript:hide_popup('my_popup<?=$data[1]?>');" onsubmit="javascript: poponload()" style="width:100%;float:left;" />
    </form>

Upvotes: 0

Views: 272

Answers (2)

Ikmal Ezzani
Ikmal Ezzani

Reputation: 1283

Instead of adding the onsubmit on the input like so:

<input type="submit" value="Tip imagine" class="buton_imagine"  
 onclick="javascript:hide_popup('my_popup<?=$data[1]?>');" 
 onsubmit="javascript: poponload()" style="width:100%;float:left;" />
</form>

Put in on the form instead

<form action="decupare_imagine.php" method="post" 
onsubmit="javascript: poponload()">....</form>

Upvotes: 1

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167172

You didn't call the poponload function! Put this in the body tag.

<body onload="poponload()">

Upvotes: 0

Related Questions