<body bgcolor="pink">
<form name="sorter" action="result.jsp" method="post">
<div align="right">
<textarea style="overflow:auto;resize:none" id="sorter2" name="sorter2" rows="4" cols="50" maxlength="100" wrap="hard"></textarea><br>
<input type="button" value="Numbers in Asc" onClick="SortNumbers()">
</div>
<div align="center">
<textarea style="overflow:auto;resize:none" id="sorter3" name="sorter3" rows="4" cols="50" maxlength="100" wrap="hard"></textarea><br>
<input type="button" value="words in Asc" onClick="SortWords()">
</div>
<p align="center">
<input type="Submit" value="View">
</p>
</form>
对于这个对应的html页面我有javascript如下它工作正常但我的问题是当我点击查看按钮它转到下一页(result.jsp)如何使用cookie传递当前页面数据以及如何显示在result.jsp页面中,提前感谢
javascript是:
function SortNumbers(){
var arr=document.getElementById("sorter2").value.split(",");
arr.sort(function(a,b){
return a-b
});
document.getElementById("sorter2").value=arr;
alert("The least value is:"+arr[0])
alert("Highest value is:"+arr[arr.length-1])
}
function SortWords() {
var inputvalues = document.getElementById("sorter3").value.split(" ");
inputvalues.sort(function (x, y) {
return x.length > y.length;
});
//document.getElementById("sorter3").value = inputvalues;
alert("smallest word is: " + inputvalues[0])
alert("longest word is: " + inputvalues[inputvalues.length - 1]);
document.getElementById("sorter3").value = inputvalues.join(' ');
}