我在order.shtml內設計了一個form如下: <form id="order" method="post" action="orderreceived_1.shtml" onsubmit="return validateOrder(order)"> 
<table border="1" cellspacing="0" cellpadding="2"> 
    <tr> 
    <th colspan="2">Customer Information: </th> 
    </tr> 
    <tr> 
      <td>Name </td> 
      <td> <input id="name" name="name" type="text" /> </td> 
    </tr> 
    <tr> 
      <td>Address </td> 
      <td> <input id="address" name="address" type="text" /> </td> 
    </tr> 
    <tr> 
      <td>Suburb </td> 
      <td> <input id="suburb" name="suburb" type="text" /> </td> 
    </tr> 
    <tr> 
      <td>State </td> 
      <td> <input id="state" name="state" type="text" /> </td> 
    </tr> 
    <tr> 
      <td>Postcode </td> 
      <td> <input id="postcode" name="postcode" type="text" /> </td> 
    </tr> 
  </table> 
</form> 請問怎樣才能把這頁的內容在orderreceived_1.shtml內顯示(一定要用post的)? 
如果可以的 能否各位指教一下用javascript 跟 不用javascript的做法?

解决方案 »

  1.   

    JS就改action,后面跟?加参数/值对,如:
    xxx.shtml?name=123
    之后再在目标页面写个读的函数.在onload读取.有后台的就好办.
    直接<%=request.getParameter("name") %>
    之类拿到参数就会直接打印在页面上.
      

  2.   

    先修改一下,
    <form id="order" method="post" action="orderreceived_1.shtml" onsubmit="return validateOrder(order)"> 
    <div id="box01">
    <table border="1" cellspacing="0" cellpadding="2"> 
        <tr> 
        <th colspan="2">Customer Information: </th> 
        </tr> 
        <tr> 
          <td>Name </td> 
          <td> <input id="name" name="name" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Address </td> 
          <td> <input id="address" name="address" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Suburb </td> 
          <td> <input id="suburb" name="suburb" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>State </td> 
          <td> <input id="state" name="state" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Postcode </td> 
          <td> <input id="postcode" name="postcode" type="text" /> </td> 
        </tr> 
      </table> 
    </div>
    </form> 1,不用JAVASCRIPT:可以把每个变量的值附加到URL后面传到orderreceived_1.shtml页,然后取出变量显示,
    2,使用JAVASCRIPT:在通过JS把ID=box01的内容(innerHTML)取出var a=document.getElementById("box01").innerHTML,然后在下一页显示变量 a 的内容,即可
      

  3.   

    能否給一下不用js的code嗎...?
    感謝!!!
      

  4.   

    存储到Cookie里,再调用不就结了。
      

  5.   

    shtml不能获取到post提交的信息吧解决你不想用get方法提交的话,有2中办法第一,把form的target设置为_blank,然后在orderreceived_1.shtml弹出页中使用opener操作第二,就是提交前将数据保存到内存cookie中,orderreceived_1.shtml从cookie中读数据
      

  6.   

    那先當作是html好了
    我先要解決的是這個問題
    post method是一定要的了
    那再用甚麼方法令orderreceived_1.html去拿回那些資料?
    請附原始碼...很急需..
      

  7.   

    第一种比较简单,你参考下
    test.html
    <form id="order" name="order" method="post" action="orderreceived_1.shtml" onsubmit="return validateOrder(order)" target="_blank"> 
    <table border="1" cellspacing="0" cellpadding="2"> 
        <tr> 
        <th colspan="2">Customer Information: </th> 
        </tr> 
        <tr> 
          <td>Name </td> 
          <td> <input id="name" name="name" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Address </td> 
          <td> <input id="address" name="address" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Suburb </td> 
          <td> <input id="suburb" name="suburb" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>State </td> 
          <td> <input id="state" name="state" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Postcode </td> 
          <td> <input id="postcode" name="postcode" type="text" /> </td> 
        </tr> 
      </table> 
    </form> orderreceived_1.shtml
    <script>
    var f=opener.document.order;//得到test.html中的表单
    document.write('name:'+f.name.value+'<br/>');
    document.write('address:'+f.address.value+'<br/>');
    document.write('suburb:'+f.suburb.value+'<br/>');
    document.write('state:'+f.state.value+'<br/>');
    document.write('postcode:'+f.postcode.value+'<br/>');
    </script>
      

  8.   

    target="_blank"<---只是用來開新的視窗嗎??因為我想是在同一個視窗顯示出來的<script>
    var f=opener.document.order;//得到test.html中的表单
    document.write('name:'+f.name.value+'<br/>');
    document.write('address:'+f.address.value+'<br/>');
    document.write('suburb:'+f.suburb.value+'<br/>');
    document.write('state:'+f.state.value+'<br/>');
    document.write('postcode:'+f.postcode.value+'<br/>');
    </script>
    以上那段...好像不行...
    不知道是不是我在用xhtml strict1.0的關係呢?因為這個是必需的
    還有呢...
    所有的js我都要先存在另一個.js內(code.js)
    如果要運行這個js 完整的原始碼應該怎麼樣才行?
      

  9.   

    如果不能打开新窗口只能用cookie传递了和xhtml是什么没关系,只要支持js就行了。不能运行可能是你没注意看我多加了一个name="order"的属性下面是cookie的,不打开新页面test.html
    <script>
    function createCookie(f){
      var v="name="+escape(f.name.value)+"&addr="+escape(f.address.value)+"&sub="+escape(f.suburb.value)
          +"&state="+escape(f.state.value)+"&pc="+escape(f.postcode.value);
      document.cookie=v;
    }
    function validateOrder(f){return true;}//为了测试你的代码重写了此函数,你自己用时改回来
    </script>
    <form id="order"  method="post" action="orderreceived_1.shtml" onsubmit="createCookie(this);return validateOrder(order);"> 
    <table border="1" cellspacing="0" cellpadding="2"> 
        <tr> 
        <th colspan="2">Customer Information: </th> 
        </tr> 
        <tr> 
          <td>Name </td> 
          <td> <input id="name" name="name" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Address </td> 
          <td> <input id="address" name="address" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Suburb </td> 
          <td> <input id="suburb" name="suburb" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>State </td> 
          <td> <input id="state" name="state" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Postcode </td> 
          <td> <input id="postcode" name="postcode" type="text" /> </td> 
        </tr> 
      </table> <input value="submit" type="submit" />
    </form> 
    orderreceived_1.shtml
    <script>
    function getCookie(key){
      var m=new RegExp(key+'=([^&]+)','gi').exec(document.cookie);
      if(m)return unescape(m[1]);else return "";
    }
    document.write('name:'+getCookie('name')+'<br/>');
    document.write('address:'+getCookie('addr')+'<br/>');
    document.write('suburb:'+getCookie('sub')+'<br/>');
    document.write('state:'+getCookie('state')+'<br/>');
    document.write('postcode:'+getCookie('pc')+'<br/>');
    </script>
      

  10.   


    document.write('name:'+getCookie('name')+'<br/>');
    document.write('address:'+getCookie('addr')+'<br/>');
    document.write('suburb:'+getCookie('sub')+'<br/>');
    document.write('state:'+getCookie('state')+'<br/>');
    document.write('postcode:'+getCookie('pc')+'<br/>');先謝過^^
    但這些是放左body內嗎?
    還是都放左script內?
    如果是放左script內
    要怎麼在orderreceived_1.shtml顯示?
      

  11.   

    楼主不会连js的一点基本都不了解吧orderreceived_1.shtml中 给你的代码需要放入script标签内才能运行function getCookie(key){
      var m=new RegExp(key+'=([^&]+)','gi').exec(document.cookie);
      if(m)return unescape(m[1]);else return "";
    }这个是获取test.html中生成的cookie的值的
      

  12.   

    這個function我知道是放左js
    只是以下的我放在.js/.shtml都只是顯示那些原始碼而已
    document.write('name:'+getCookie('name')+'<br/>');
    document.write('address:'+getCookie('addr')+'<br/>');
    document.write('suburb:'+getCookie('sub')+'<br/>');
    document.write('state:'+getCookie('state')+'<br/>');
    document.write('postcode:'+getCookie('pc')+'<br/>');我程度比較低
    所以問的可能很幼稚...但真的不懂才問..對不起喔..
      

  13.   

    try(IIS5通过):form.htm<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>form</title>
    </head><body>
    <form id="order" method="post" action="orderreceived_1.shtml"> 
    <table border="1" cellspacing="0" cellpadding="2"> 
        <tr> 
        <th colspan="2">Customer Information: </th> 
        </tr> 
        <tr> 
          <td>Name </td> 
          <td> <input id="name" name="name" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Address </td> 
          <td> <input id="address" name="address" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Suburb </td> 
          <td> <input id="suburb" name="suburb" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>State </td> 
          <td> <input id="state" name="state" type="text" /> </td> 
        </tr> 
        <tr> 
          <td>Postcode </td> 
          <td> <input id="postcode" name="postcode" type="text" /> </td> 
        </tr> 
      </table> 
    </form> </body></html>order.shtml<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>order</title>
    </head><body><!--#include file="form.htm"-->
    <input type=button onclick="submitForm()" value="提交"><script language="javascript">
    <!--
    function $(id){return document.getElementById(id)}function validateOrder(id){
    return true;//for test
    }function submitForm(){
    if (validateOrder("order")){
    document.cookie=="name="+escape($("name").value)+"&address="+escape($("address").value)+"&suburb="+escape($("suburb").value)
          +"&state="+escape($("state").value)+"&postcode="+escape($("postcode").value);
    document.getElementById('order').submit()
    }
    }
    //-->
    </script></body></html>orderreceived_1.shtml
    <!--#include file="form.htm"--><SCRIPT language=javascript>
    <!--
    function getCookie--(key){
      var m=new RegExp(key+'=([^&]+)','gi').exec(document.cookie);
      if(m)return unescape(m[1]);else return "";
    }function getCookie(Name) {//读Cookie中Name的值
    var search = Name + "="
    var Cookie =document.cookie;
    if (Cookie.length <= 0 || Cookie.indexOf(search)==-1)return "";// cookie 不存在 或 'openid' 不存在,返回 0
    else{
    var tmp= Cookie.split(search)[1].split("&")[0]
    return unescape(tmp)
    }
    }
    function $(id){return document.getElementById(id)}$("name").value=getCookie('name')
    $("address").value=getCookie('address')
    $("suburb").value=getCookie('suburb')
    $("state").value=getCookie('state')
    $("postcode").value=getCookie('postcode')
    //-->
    </SCRIPT>
      

  14.   

    我用了你的方法 在orderreceived_1.shtml只顯示了1個table跟以下的交字:
    $("name").value=getCookie('name') $("address").value=getCookie('address') $("suburb").value=getCookie('suburb') $("state").value=getCookie('state') $("postcode").value=getCookie('postcode')
    ……還有不用form.htm分出來...
    只是需要order_1跟orderreceived_1這兩個頁面@@...
      

  15.   

    showbo 和caiying已经说得很清楚啦!~
    要说的都说啦~!没有想到的他们也说啦!~
    楼主还是自己好好学学JS了再说吧~!