<input type=text name=q_name maxlength=15 value='$_GET[q_name]'>

解决方案 »

  1.   

    不会的!写成
    <?php
    echo "
    <body onload = SetValue()>
    ...
    <script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value = '$_GET[q_name]';
    }
    </script><form name = frm_a>
    ...
    <input type=text name=q_name maxlength=15>
    <input type=submit>
    </form>
    ";
    ?>
    执行后填入123
    提交
    查看源文件
    可见
    <body onload = SetValue()>
    ...
    <script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value = '123'; //已经在这里了
    }
    </script><form name = frm_a>
    ...
    <input type=text name=q_name maxlength=15>
    <input type=submit>
    </form>不过若你的php版本低于4.1.0那么
    $_GET 就要写作 $HTTP_GET_VARS
      

  2.   

    我的php是PHP-4.0.6-7.9ex,让我试试
      

  3.   

    echo "<script language = javascript>";
    echo "function SetValue(){";
    echo "document.frm_a.q_name.value = '".$_GET[q_name]."'";
    echo "}";
    echo "</script>";
      

  4.   

    xuzuning(唠叨):好像还是不行,我试了你说的$HTTP_GET_VARS也取不出来,这是怎么回事啊??<?php
    echo "
    <html>
    <body onload = SetValue()>
    <script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value='$_HTTP_GET_VARS[q_name]";
    }
    </script><form name = frm_a>
    <input type = text name = q_name maxlength = 15>
    <input type = submit>
    </form>
    </html>
    ";
    ?>submit了以后,我看到的是document.frm_a.q_name.value = '';没有值啊!
      

  5.   

    <form name = frm_a method="GET">
    <input type = text name = q_name maxlength = 15>
    <input type = submit>
    </form>加上method="GET"试试?
      

  6.   

    <?php
    echo "
    <html>
    <body onload = SetValue()>
    <script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value='$_HTTP_GET_VARS[q_name]";//这句有问题吧,'$_HTTP_GET_VARS[q_name]";引号不对称哦……
    }
    </script>
      

  7.   

    我用的环境是linux7.1+apache+mysql+phpphp用的就是linux下自带的,应该是4.0的吧,ftp上传用的是smartftp,上传后执行,本地机器为window2000 pro,ie6.0,在input中输入123,submit以后页面提交,地址栏变为http://xxx.xx.xx.xx:8088/a.php?q_name=123,察看源代码,看到的是document.frm_a.q_name.value = '',没有值,所用php的程序就在上面。ctq77ctq(ctq77ctq),难道还有别的地方不对吗?
      

  8.   

    chairj(麽麽茶) 这个问题我看了一下,现在的程序里确实是两个单引号,帖子里的打错了
      

  9.   

    ctq77ctq(ctq77ctq)你能把你测试成功的程序发给我吗?我的信箱是[email protected]
      

  10.   

    document.frm_a.q_name.value='<?=$_HTTP_GET_VARS[q_name]?>';这样写呢
      

  11.   

    这样的话,察看源代码发现:document.frm_a.q_name.value='<?=?>';
      

  12.   

    楼上的各位,你们有谁能发一份测试过的程序到我的信箱吗?小弟在这里先谢过了,我的信箱[email protected]
      

  13.   

    <?phpecho "
    <body onload = SetValue()><script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value = '$_GET[q_name]';
    }
    </script>$q_name  <form name = frm_a><input type=text name=q_name maxlength=15>
    <input type='submit' name='submit' value='提交'></form>
    ";
    ?>可以啊
      

  14.   

    <?php
    echo "
    <html>
    <body onload = SetValue()>
    <script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value='$HTTP_GET_VARS[q_name]';
    }
    </script><form name = frm_a>
    <input type = text name = q_name maxlength = 15>
    <input type = submit>
    </form>
    </html>
    ";
    ?>提交以后再看
      

  15.   

    php.ini 里应该是这样的吧
    register_globals = on
      

  16.   

    chqiang(攀)你说的没错,这样的话值是显示在页面上了,但是我看源代码依然还是document.frm_a.q_name.value = '';你能告诉我这是为什么吗?怎么解决呢?
      

  17.   

    是PHP的变量和JS的变量之间转换的问题吧??
      

  18.   

    function SetValue(){
        document.frm_a.q_name.value = '$HTTP_GET_VARS[q_name]';
    }
    是这样写的吗?
      

  19.   

    咳~犯了这么低级的错误,xuzuning(唠叨)谢了,结账!
      

  20.   

    还是段
    <?phpecho "
    <body onload = SetValue()><script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value = '$HTTP_GET_VARS[q_name]';
    }
    </script><form name = frm_a><input type=text name=q_name maxlength=15>
    <input type='submit' name='submit' value='提交'></form>$q_name 
    ";
    ?>
    结果是:
    <body onload = SetValue()><script language = javascript>
    function SetValue(){
        document.frm_a.q_name.value = '111111111';   //看有啊。
    }
    </script><form name = frm_a><input type=text name=q_name maxlength=15>
    <input type='submit' name='submit' value='提交'></form>111111111