Jump to content

[SOLVED] popup window won't work, why?


Darkmatter5

Recommended Posts

This line is in the page the button is pressed on

 

<script type="text/javascript">
function open_win(url_add) {
    window.open(url_add, 'welcome', 'toolbar=yes,location=yes,
    directories=no,status=no,menubar=yes,scrollbar=no,resizable=no,
    copyhistory=yes,width=300,height=200');
}
</script>

 

This code is what executes the table generation also on the same page as the javascript

<?php $ec->show_filing(); ?>

 

Here's the show_filing() code

function show_filing() {
            include 'library/config.inc.php';
            $conn=mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
            mysql_select_db($dbnamemain);
            
            $query=mysql_query("SELECT cab_name, fol_name, items.*
                                FROM items
                                JOIN folders ON(items.folder_id=folders.folder_id)
                                JOIN cabinets ON(cabinets.cabinet_id=folders.cabinet_id)
                                ORDER BY cabinets.cab_name ASC, folders.fol_name ASC
                                ") or die(mysql_error());
            echo "<p>
                  <table width='100%' border='0' cellspacing='1' cellpadding='3'>
                    <th width='200'>PATH<img src='images/up.gif'><img src='images/down.gif'></th>
                    <th width='200'>NAME<img src='images/up.gif'><img src='images/down.gif'></th>
                    <th>DESCRIPTION</th>
                    <th width='70'>ACTION</th>";
            
            $filltog=0;
            while($row=mysql_fetch_array($query)) {
                if($filltog==0) { $fillcolor="#A8231C"; }
                else { $fillcolor="#686615"; }
                echo "<tr bgcolor='$fillcolor'>
                        <td>$row[cab_name] -> $row[fol_name] -> </td>
                        <td>" .substr($row['item_name'],0,100). "</td>
                        <td>$row[item_description]</td>
                        <td align='center'><input type='button' class='button' value='delete' onclick='open_win('delete.php?item_id=$row[item_id]')'> | Edit</td>
                      </tr>";
                if($filltog==0) { $filltog=1; }
                else { $filltog=0; }
            }
            echo "</table>";
            
            mysql_close($conn);
        }

 

Nothing happens when I press the button.

Link to comment
https://forums.phpfreaks.com/topic/129611-solved-popup-window-wont-work-why/
Share on other sites

you can't have single quotes inside single quotes here:

onclick='open_win('delete.php?item_id=$row[item_id]')'

change that line to this:

                        <td align='center'><input type='button' class='button' value='delete' onclick=\"open_win('delete.php?item_id=$row[item_id]')\"> | Edit</td>

Nope no java errors, just nothing, I click the button and it does nothing.

 

Here's the source after I click the button.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>E-Cabinet Filing Page</title>
<script type="text/javascript">
function open_win(url_add) {
    window.open(url_add,"_blank", "toolbar=yes,location=yes,
    directories=no,status=no,menubar=yes,scrollbar=no,resizable=no,
    copyhistory=yes,width=300,height=200");
}
</script>
<link href="library/config.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="main">
  <div id="banner">
    <table width="100%" height="100%" border="0" align="center">

      <tr>
        <td width="50%" valign="bottom"></td>
        <td align="right" valign="bottom">October 22, 2008, 12:17:13 PM</td>
      </tr>
    </table>
  </div>
  <div id="content">
    <div id="c_main">

      <div id="cm_menu">
        <table width="100%">
          <tr>
            <td><a href='index.php'>MAIN</a> | <a href='forums.php'>FORUMS</a> | <a href='admin.php'>SITE ADMIN</a></td>
            <td align="right">E-Cabinet version:  1.2</td>

          </tr>
        </table>
      </div>
      <div id="cm_content">
         <span class="style3">ORGANIZATION EXPLAINATION</span><br>
         Cabinets are broken down into folders and folders are broken down into<br>
         items.  See the image below for a graphical depiction of the cabinet,<br>

         folder, and item heiarchy.<p>
         <a href="res_cabinets.php">CABINETS</a> | <a href="res_folders.php">FOLDERS</a> | <a href="res_items.php">ITEMS</a>
         <p>
                  <table width='100%' border='0' cellspacing='1' cellpadding='3'>
                    <th width='200'>PATH<img src='images/up.gif'><img src='images/down.gif'></th>

                    <th width='200'>NAME<img src='images/up.gif'><img src='images/down.gif'></th>
                    <th>DESCRIPTION</th>
                    <th width='70'>ACTION</th><tr bgcolor='#A8231C'>
                        <td>Bills -> Telephone, Cable & Internet -> </td>
                        <td>something</td>
                        <td>lhhklhjlh</td>

                        <td align='center'><input type='button' class='button' value='delete' onclick="open_win('delete.php?item_id=9')"> | Edit</td>
                      </tr><tr bgcolor='#686615'>
                        <td>Investments -> Primerica -> </td>
                        <td>Stock1</td>
                        <td></td>
                        <td align='center'><input type='button' class='button' value='delete' onclick="open_win('delete.php?item_id=10')"> | Edit</td>

                      </tr><tr bgcolor='#A8231C'>
                        <td>Investments -> Primerica -> </td>
                        <td>Primerica transaction - 093008</td>
                        <td>Mutual Funds transactions on 093008</td>
                        <td align='center'><input type='button' class='button' value='delete' onclick="open_win('delete.php?item_id=8')"> | Edit</td>
                      </tr></table>      </div>

      <div id="cm_footer">
        Copyright &copy 2008 by Mark Lalich.  All rights reserved.<br>
        <a href="donate.php">Donate to the E-Cabinet project</a>
      </div>
    </div>
    <div id="c_tools">
      <div id="ct_login">

        <div align="center"><b>ACCOUNT INFO</b><p>
                      <span class='welcome_text'>Welcome <strong>mark.lalich</strong>!</span><br>
                      Edit your profile | <a href='logout.php' tabindex='5'>Logout</a><p>
                      <a href='help.php' tabindex='7'>Help</a></div>
      </div>

      <div id="ct_title"></div>
    </div>
  </div>
</div>
</body>
</html>

ah, looks like JS doesn't like it when you span lines on that function:

 

<script type="text/javascript">
function open_win(url_add) {
    window.open(url_add,"_blank", "toolbar=yes,location=yes," +
    "directories=no,status=no,menubar=yes,scrollbar=no,resizable=no," +
    "copyhistory=yes,width=300,height=200");
}
</script>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.