Search code examples
phpjavascripthtmlpopuphref

href with onclick javascript pop-up


i have this javascript:

<SCRIPT LANGUAGE="JavaScript">
<!-- 

// Generated at http://www.csgnetwork.com/puhtmlwincodegen.html 
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=400,left = 283,top = -16');");

}

// -->
</script>

i want to use an href with a javascript popup function but its not working. here is my code

 <?php
    echo "<a href = '#' onClick='javascript:popUp('editdelete.php?emoticon_text=$emoticon_text&id=$id')'><img src='update.png'></a>";
    ?>

but its not working

(the $emoticon_text and the $id will be passed to the pop up window using $_GET function.)

thanks


Solution

  • You are mixing your quotes usage. Please try the following:

    <a href = '#' onClick='javascript:popUp("editdelete.php?emoticon_text=$emoticon_text&id=$id")'><img src='update.png'></a>
    

    Note the double quotes inside javascript:popUp inplace of single quote as you have in your question.

    Update:

    After OP's comment below:

    <?php echo "<a href = '#' onClick='javascript:popUp(\'editdelete.php?emoticon_text=$emoticon_text&id=$id\')'‌​><img src='update.png'></a>"; ?>