I'm using prototype at my page.When i click the link,new window is opening but when i click the other link,same window is opening again.here is my code; <a href="#" onclick="dialog();">LINK1</a> <script type="text/javascript"> function dialog() { Dialog.alert({url: "aaa1.html", options: {method: 'get'}}, {className: "alphacube", width:700, okLabel: "Close"}); } WindowCloseKey.init(); </script> <br><a href="#" onclick="dialog();">LINK2</a></center> <script type="text/javascript"> function dialog() { Dialog2.alert({url: "aaa2.html", options: {method: 'get'}}, {className: "alphacube", width:700, okLabel: "Close"}); } WindowCloseKey.init(); </script> at both cases,aaa2.html is opening.Please help me with this!
That would be because you've redefined your dialog function (essentially overwritten the first one with your second one). Normally, I would do something like: <a href="#" onclick="dialog('aaa1.html');">LINK1</a> <script type="text/javascript"> function dialog(url_to_display) { Dialog.alert({url: url_to_display, options: {method: 'get'}}, {className: "alphacube", width:700, okLabel: "Close"}); } WindowCloseKey.init(); </script> <br><a href="#" onclick="dialog('aaa2.html');">LINK2</a></center> HTML: or something like that...
Hi. I've got a similar problem, but... just cannot cope with it. while ($row= mysql_fetch_array($numresults)) { $id= $row["id"]; $user = $row["user"]; echo "<a href='#' onclick='dialog();'><strong>$id</strong> - <strong>$user</strong></a>"; echo "<script type='text/javascript'>function dialog() { Dialog.alert({url: 'one.php?page=$id', options: {method: 'get'}}, {className: 'alphacube', width:560, okLabel: 'Close'}); } </script>"; $count++ ; } ... the only $id I GET as a result is its latest owned value. Defiantly, overwriting functions, but ... I just cannot solve the problem. Please, help me with this!
Pretty much the same answer as I gave mustaineoz... just move your dialog function out of the loop. Again this is untested code, so don't be surprised if it doesn't work exactly... echo "<script type='text/javascript'>function dialog(id_to_display) { Dialog.alert({url: 'one.php?page=' + id_to_display, options: {method: 'get'}}, {className: 'alphacube', width:560, okLabel: 'Close'}); } </script>"; while ($row= mysql_fetch_array($numresults)) { $id= $row["id"]; $user = $row["user"]; echo "<a href='#' onclick='dialog($id);'><strong>$id</strong> - <strong>$user</strong></a>"; $count++ ; } PHP: