<script language=javascript>
 function hello()
  {
    alert("hello");
   }
</script>
<form action = "$_PHP_SELF">
 <input type = "button" name = "button1" value = " button " onclick = "hello()" >
</form>提示为了防止出现错误最好不要将每个button的名称与值写成相同的名字

解决方案 »

  1.   

    这样得函数得用JS写,PHP不能这样调用!
      

  2.   

    那怎么通过button来调用PHP的函数呢?
      

  3.   

    <?php
     function hello()
      {
        echo "hello";
       }
    <form action = "">
     <input type = "button" name = "button" value = "button" onclick = "hello()" >
    </form>
    为什么按下button时不能实现hello函数
    **********************************************************************
    <?php
     function hello()
      {
        echo "false";
       }
    <form action = "">
    <input type = "button" name = "button" value = "button" onclick = "<? hello();?>" >
    </form>
    为什么按下button时不能实现hello函数
      

  4.   

    <?php
     function hello()
      {
        echo "hello";
       }
    <form action = "">
     <input type = "button" name = "button" value = "button" onclick = "hello()" >
    </form>
    为什么按下button时不能实现hello函数
    **********************************************************************
    <?php
     function hello()
      {
        echo "false";
       }
    <form action = "">
    <input type = "button" name = "button" value = "button" onclick = "<? hello();?>" >
    </form>
    要用 onclick = "<? hello();?>"  原理跟 <? echo "true";?>一样php函数就要在php语言块中调用
      

  5.   

    楼上的,我用了onclick = "<? hello();?>"  可还是实现不了啊!
      

  6.   

    晕啊
    我建议楼主先去搞清楚web程序的原理,这样对你以后写web程序都很有帮助的
      

  7.   

    和.net的onserverclick有点像了哦....