我在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的做法?
<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的做法?
xxx.shtml?name=123
之后再在目标页面写个读的函数.在onload读取.有后台的就好办.
直接<%=request.getParameter("name") %>
之类拿到参数就会直接打印在页面上.
<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 的内容,即可
感謝!!!
我先要解決的是這個問題
post method是一定要的了
那再用甚麼方法令orderreceived_1.html去拿回那些資料?
請附原始碼...很急需..
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>
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 完整的原始碼應該怎麼樣才行?
<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>
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顯示?
var m=new RegExp(key+'=([^&]+)','gi').exec(document.cookie);
if(m)return unescape(m[1]);else return "";
}这个是获取test.html中生成的cookie的值的
只是以下的我放在.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/>');我程度比較低
所以問的可能很幼稚...但真的不懂才問..對不起喔..
<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>
$("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這兩個頁面@@...
要说的都说啦~!没有想到的他们也说啦!~
楼主还是自己好好学学JS了再说吧~!