按下按钮后包括php页面

时间:2014-12-05 07:34:22

标签: php

我们在for循环中有四个同名button1的按钮。如果我们按下一个按钮就必须为此加载php页面,我们使用isset函数,但编码不能以理想的方式正常工作,请帮助......

<!DOCTYPE html>
<html>
<head>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<script>
  $(document).ready(function(){
  $('.myButton').click(function() {
    var $ct = $(this).next("div.container");
    if (this.value == 'collapse') {
  this.value = 'expand';
  $ct.hide("slow");
 $('.myButton').parent().show("slow");
    } else {
  this.value = 'collapse';
  $ct.show("slow");
 $('.myButton').not($(this)).parent().hide("hide");
    }

  });
});
</script>



</head>
<body>
<?php
for($i=0;$i<=3;$i++)
{
echo"<div class='main' style='position:relative;border:1px solid #A5BEBE;background-        color:#E7EFEF;width:84%;  '> 
<b> sometext:-</b><a href='#'>$url</a><br>
<b>sometext :</b>$b<br>
</p>
<input type='button' value='expand' class='myButton'  name='button1' target='".$i."'       onclick='clickButton(this)'        style='position:absolute;left:85%;top:4%;background:#B20000;color:white;width:70px;height:20px;font-        size:15px;' >";

echo "<div  class='container'  style='display:none;background:white; '>

  <b> sometext:-</b><a href='#'>$url</a><br>
<b>sometext :</b>$b<br>
<b>sometext :</b>$c<br>
</p>";
if(isset($_GET['button1']))
{ 
echo"<script>alert('msg1');</script>";
include('function.php'); 
} 
echo "</div>";

echo "</div>";

}
?>

</body>
</html>

在上面的代码中没有出现警告消息。分别按下每个按钮时应调用此警报...

1 个答案:

答案 0 :(得分:0)

我认为你错过了php和javascript(或者这个场合的jquery)在两个完全不同的时刻执行的事实。前者由服务器执行,输出发送到将执行后者的客户端(浏览器)。因此,我不会认为您的提醒会被显示,因为除非通过网页的调用来定义$ _GET [&#34; button1],否则代码甚至不会存在于客户端。

相关问题