2012-12-18 47 views
1

我使用JavaScript和PHP爲我的彈出窗口。該計劃是將父頁面上的行ID傳遞給彈出窗口。彈出窗口不起作用

它的正常工作與此代碼:出現

<a href="#" onclick="PopupCenter('example.php', 'myPop1',500,400); " class="add"><img src='images/buttons/edit.png' title='Edit Content'></a> 

彈出。但是當我嘗試添加?textID=<?$row['textID']?>,這是我使用通過行ID,像這樣結束代碼:

<a href="#" onclick="PopupCenter('example.php?textID=<?$row['textID']?>', 'myPop1',500,400); " class="add"><img src='images/buttons/edit.png' title='Edit Content'></a> 

彈出不起作用。它似乎只是刷新頁面。感謝您的幫助。

這裏是我的完整代碼

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<?php 
    include("global.php"); 
?> 

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta charset="utf-8"> 
<title>About | ILAM</title> 

<!-- main css --> 
<link href="style.css" rel="stylesheet" type="text/css"> 
<link href="styleAdmin.css" rel="stylesheet" type="text/css"> 

<script type= "text/javascript"> 
    <!-- showHideDiv --> 
    function divHideShow(divToHideOrShow){ 
     var div = document.getElementById(divToHideOrShow); 
     if (div.style.display == "block"){ 
      div.style.display = "none";} 
     else{ 
      div.style.display = "block";} 
    }   

    <!-- popUp --> 
     function PopupCenter(pageURL, title,w,h) 
      { 
       var left = (screen.width/2)-(w/2); 
       var top = (screen.height/2)-(h/2); 
       var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left); 
      } 
</script> 
</head> 

<!-- Body --> 
<body> 
<div id="pagewrap"> 
    <!-- Header --> 
    <div id="header"> 
     <div class="floating-menu"> 
      <div class="logo"><img src="images/static/ilamLogo.png"></div> 
      <div class="translator"> 
      </div> 
      <ul> 
       <li><a href="join.php">Join Us!</a></li> 
       <li><div class="indent">&nbsp;</div></li> 
       <li><a href="contact.php">Contact</a></li> 
       <li><a href="career.php">Career</a></li> 
       <li><a href="gallery.php">Gallery</a></li> 
       <li><a href="facilities.php">Facilities</a></li> 
       <li><a href="courses.php">Courses</a></li> 
       <li><a href="#" class="active">About</a></li> 
       <li><a href="index.php">Home</a></li> 
       <li><a href="javascript:divHideShow('menuContentBanner');divHideShow('menuContentBannerText');divHideShow('menuOpenPost');divHideShow('menuMainPost');divHideShow('menuFooterLeft');divHideShow('menuFooterMiddle');divHideShow('menuFooterRight');">Admin</a></li> 
      </ul> 
     </div> 
    </div> 
    <!-- //Header --> 
    <!-- ContentBanner --> 
    <div id="contentBanner"> 
     <div id="menuContentBanner" class="menuBarStyle"> 
      <div class="addEditDelete"> 
       <ul> 
       <li><a href="addImage.php"><img src="images/buttons/edit.png" title="Edit Image"></a></li> 
       </ul> 
      </div> 
     </div> 
    <img src="images/headers/aboutHeader.jpg"></div> <!--BannerImage -->  
    <div class="textLeft"> 
     <div id="menuContentBannerText" class="menuBarStyle"> 
      <div class="addEditDelete"> 
       <ul> 
       <li><a href="#" onclick="PopupCenter('edit_article.php', 'myPop1',500,400); " class="add"><img src="images/buttons/edit.png" title="Edit Content"></a></li> 
       </ul> 
      </div> 
     </div> 
    <h3>As an Academic Institution.</h3><p> ILAM takes to heart its responsibilities, not only to its students, but also to its team, and community</p></div> <!-- BannerText --> 
    <!-- //ContentBanner --> 
    <!-- Content: Blue --> 
    <div id="content"> 
     <!-- SidePost --> 
     <aside id="sidebar"> 
      <section class="widget"> 
       <ul> 
        <li><a href="#"><img src="images/buttons/factsbtn.png" onmouseover="this.src='images/buttons/factsbtnHover.png'" onmouseout="this.src='images/buttons/factsbtn.png'"></a></li> 
        <li><a href="#"><img src="images/buttons/testibtn.png" onmouseover="this.src='images/buttons/testibtnHover.png'" onmouseout="this.src='images/buttons/testibtn.png'"></a></li> 
        <li><a href="#"><img src="images/buttons/promosbtn.png" onmouseover="this.src='images/buttons/promosbtnHover.png'" onmouseout="this.src='images/buttons/promosbtn.png'"></a></li> 
       </ul> 
      </section> 
     </aside> 
    <!-- //SidePost --> 
    <!-- OpenerPost --> 
     <article class="openerPost"> 
      <table> 
       <tr> 
        <div id="menuOpenPost" class="menuBarStyle"> 
         <div class="addEditDelete"> 
         <ul> 
          <li><a href="#" onclick="PopupCenter('example.php?promoID=<?=$row['promo_id']?>', 'myPop1',400,400); "><img src="images/buttons/edit.png" height="27" width="65"></a></li> 
         </ul> 
         </div> 
        </div> 
       </tr> 
       <tr> 
        <td><?php 
          $query="SELECT * from text_tb WHERE textID = '1'"; 
          $result=mysql_query($query); 
          if (!$result) { 
           echo 'Could not run query: ' . mysql_error(); 
           exit; 
          } 
          $row = mysql_fetch_row($result); 
          echo $row[1]; // the email value 
          ?> 
        </td> 
       </tr> 
      </table> 
     </article> 
    </div> 
    <!-- //OpenerPost --> 
    <!-- Content: White --> 
    <div id="content"> 
     <article class="mainPost"> 
      <table> 
       <tr> 
        <div id="menuMainPost" class="menuBarStyle"> 
         <div class="addEditDelete"> 
         <ul> 
          <li><a href="addImage.php"><img src="images/buttons/edit.png" title="Edit Content"></a></li> 
         </ul> 
         </div> 
        </div> 
       </tr> 
       <tr><td class="title">Our Mission</td></tr> 
       <tr> 
        <td><p>As an academic institution, ILAM takes to heart its responsibilities, not only to its students, 
        but also to its team, and community. We know that in addition to reaching our vision for the school, ILAM has 
        a role and certain duties that it has to carry out.</p></td> 
       </tr> 

       <tr> 
        <td class="subtitle">For the Students.</td> 
       </tr> 
       <tr> 
        <td><p>International Language Academy Manila (I.L.A.M.) is a premier language school in Makati 
        City, Philippines whose mission is to provide quality education to professionals and 
        non-professionals aiming to be proficient in English. The school takes pride in its ESL/EFL 
        courses such as: Functional Grammar, Conversation, Business Writing, Business English, 
        Pronunciation, IELTS review, TOEIC review, etc. which are all taught in a multidisciplinary 
        setting to ensure comprehensive skill development in the four areas of communication (listening, 
        speaking, reading, and writing). Apart from teaching English, the school also intends to inculcate strong intercultural 
        awareness among its students by integrating outdoor activities in its curriculum. </p></td> 
       </tr> 
       <tr> 
        <td class="subtitle">For the Community.</td> 
       </tr>    
       <tr>     
        <td><p>As an academic institution, ILAM takes heart to its responsibilities in promoting education and tourism in the country, which is the reason behind its partnership with the Bureau of Immigration and various multinational companies for English training. It aims to show its foreign students how much the 
        country has improved, and that the Philippines is a place where they can always find another 
        home. ILAM goes beyond the technicalities of language. It offers students the opportunity to 
        foster a deeper understanding of various cultures and thus, enables them to appreciate more the 
        beauty of language as they get to communicate and interact with different people.</p></td> 
       </tr> 
       <tr> 
        <td class="subtitle">For its Team.</td> 
       </tr> 
       <tr> 
        <td><p>As an academic institution, ILAM takes heart to its responsibilities in promoting education 
        and tourism in the country, which is the reason behind its partnership with the Bureau of Immigration and various 
        multinational companies for English training. It aims to show its foreign students how much the 
        country has improved, and that the Philippines is a place where they can always find another 
        home. ILAM goes beyond the technicalities of language. It offers students the opportunity to 
        foster a deeper understanding of various cultures and thus, enables them to appreciate more the 
        beauty of language as they get to communicate and interact with different people.</p></td> 
       </tr> 
      </table> 
     </article> 
    </div> 

    <footer id="footer"> 
     <table> 
      <tr> 
       <td> 
        <div id="menuFooterLeft" class="menuBarStyle"> 
         <a href="addImage.php"><img src="images/buttons/edit.png" title="Edit Content"></a> 
        </div> 
        <h3>Let's Meet</h3> 
        <p>2/F Makati Creekside Mall Bldg. Amorsolo Cor. VA Rufino St. Legazpi Village, Makati City Philippines</p></td> 
       <td> 
        <div id="menuFooterMiddle" class="menuBarStyle"> 
         <a href="addImage.php"><img src="images/buttons/edit.png" title="Edit Content"></a> 
        </div> 
        <h3>Let's Talk</h3> 
        <p>Telephone: 632-8400285/519 9502<br>Cellphone: 0917-5324332</p></td> 
       <td> 
        <div id="menuFooterRight" class="menuBarStyle"> 
          <a href="addImage.php"><img src="images/buttons/edit.png" title="Edit Content"></a> 
        </div> 
       <h3>The Affiliates</h3> 
       <p>Accenture<br> 
       Asian Institute of Management<br> 
       ConveyThis<br> 
       The Little Web Directory<br></td> 
      </tr> 
      <tr> 
       <td class="copyright">Copyright &copy; 2012 ILAM</td> 
      </tr> 
     </table> 
    </footer> 
</div> 
<!-- /#pagewrap --> 

</body> 
</html> 
+0

是什麼'<? $ row ['textID']?>'...如果它的PHP,那麼你需要使用'<?php echo $ row ['textID']?>' – jamis0n

回答

1

你需要使用echo,如:

<?php echo($row['textID']) ?> 
+0

仍然無法正常工作。請幫忙。我已經發布了我的完整代碼。 – jamie

+0

你需要做'<?php echo($ row ['promo_id'])?>'not'<?= $ row ['promo_id']?>' –

+0

非常感謝您的幫助,但我找到了更好的解決方案:) – jamie

1

看起來是PHP。要插入PHP變量到HTML,使用echo,像這樣:

<a href="#" 
    onclick="PopupCenter('example.php?textID=<?php echo $row['textID'] ?>', 'myPop1',500,400); " class="add"> 
    <img src='images/buttons/edit.png' title='Edit Content'> 
</a> 
+0

仍然無法正常工作。請幫忙。我已經發布了我的完整代碼。 – jamie

+0

當您在加載頁面後查看源代碼時,該標籤內容的外觀如何? – jamis0n

+0

非常感謝幫助,但我發現了一個更好的解決方案:) – jamie

0

如果速記是允許的,這應該工作

<?=$row['textID']?> 
+0

仍然無法正常工作。請幫忙。我已經發布了我的完整代碼。 – jamie

+0

非常感謝您的幫助,但我找到了更好的解決方案:) – jamie

+0

您可以回答自己的問題並接受您的答案以關閉此主題,並恭喜 –