0

the flow is: a php page calls an ajax function that displays a list of user in a table without refreshing the pages. in this table, i put a delete and edit link. I have no problem with the delete link however, i'm stuck at the edit link.

what I'm trying to do is, when a user click edit link, there will appear a popup window, there, they can update the details of the user, but it appears that my popup window is not appearing.

the javascript function is:

<script type="text/javascript">
function newWindow(url) { 
var x,y;
x = screen.width-35;
y = screen.height-30;
var win =       window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
        'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
    }

i put the function at the top of the page.

this is the php code to call java function in html tag

echo "<td>" . '<a href="javascript: newWindow("/test/HTMLPages/popup_update_user.html")">edit</a>' . "</td>";

is it possible??

i checked it its my URL that wrong, but that is not the problem. the popup does not appear at all. i need advise on this matter.

UPDATE:

this is the correct code for calling javascript in tag within php:

 <?php
    echo "<td>" . "<a href=\"#\" onclick=\"newWindow('popup_update_user.html')\">edit</a>". "</td>"; ?>

:D

1 Answer 1

1

The problem is that in the echo you are opening and closing the statement before calling the javascript function.

And don't call the function in the "href", call it from "onclick".

Try this:

echo "<td> <a href=\"#\" onclick=\"newWindow('/test/HTMLPages/popup_update_user.html')\">edit</a></td>";

EDIT: Working example

<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript">
            function newWindow(url) { 
            var x,y;
            x = screen.width-35;
            y = screen.height-30;
            var win =       window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
                    'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
                }
    </script>
    </head>
    <body>
        <table>
            <tr>
                <?php
                echo "<td> <a href=\"#\" onclick=\"newWindow('/test/HTMLPages/popup_update_user.html')\">edit</a></td>";
                ?>
            </tr>
        </table>
    </body>
</html>
Sign up to request clarification or add additional context in comments.

7 Comments

thank you. but when i tried, it did not work. the page says object not found'
meaning?? sorry for the non-stop questions.. i'm new to this.
it opens a new window right ? but in that window it says "object not found" right ? If that's the case then the url : "/test/HTMLPages/popup_update_user.html" is wrong
It depends the browser you are using, but if you are using any recent browser it should work, but for the sanity check try this. var win = window.open(url,'glossaryWindow_'+Math.floor((Math.random()*100)+1),'toolbar=no,directories=no,width=500,height=500'+ 'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
Replace your var win with that
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.