dqsh30374 2012-07-10 13:33
浏览 66

如何使用PHP填充输入字段

I'm trying to write a simple calculator html page where I ask for two numbers in separate text boxes, have the user click a button and then the result gets stored into a third text box. I'm trying to using PHP to resolve this but can't seem to display it the way I want. the echo line works fine, but I don't want that;

From HTML

     <form action="Add.php" method="get">
        <input for='num1' type="text"  name="num1" />
        <input for='num2' type="text" name="num2" />

        <input type="submit" value="Add Them" />
        <input type="text" name="AnswerBx" id="SumTotalTxtBx"/>
    </form> 

Add.php

     <?php 
        $num1 = $_GET["num1"];
        $num2 = $_GET['num2'];
        $sum = $num1+$num2;
        //echo "$num1 + $num2 = $sum";

        document.getElementById("SumTotalTxtBx").value = $sum;
    ?>
  • 写回答

4条回答 默认 最新

  • doulu4413 2012-07-10 13:38
    关注

    You are mixing PHP and Javascript here, go back to the PHP manual at : http://php.net/manual and read out how php works and interacts with the user.

    Javascript is basicaly run on the client side while PHP is run on the server. You REQUEST php something and it returns a new HTML page for you.

    That being said, its a too broad topic to help you fix your error.

    Good luck

    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题