<html>
<head>
<script language="JavaScript" type="text/javascript">
function getValue(){
var win = window.open('subpage.html');
}
//simulate a bit of server process
function simulateServerProcessing(){
var arrSearch = location.search.split("?");
if(arrSearch.length > 1){ // has been submitted
document.getElementById("textoutput").style.display = "block";
document.getElementById("textinput").style.display = "none";
arrValuePairs = arrSearch[1].split("&");
var strTyped = "";
var strSelected = "";
for(var i = 0; i < arrValuePairs.length; i++){
arrCurrent = arrValuePairs[i].split("=");
switch(arrCurrent[0]){
case "textinput1" : {
strTyped = arrCurrent[1];
break;
}
case "hiddenvalue" : {
strSelected = arrCurrent[1];
break;
}
default : {
break;
}
}
}
document.getElementById("textoutput").innerText = "You Typed " +
strTyped +
" and selected " +
strSelected + ".";
}
else{ // is loaded for first time
document.getElementById("textoutput").style.display = "none";
document.getElementById("textinput").style.display = "block";
}
}
</script>
</head>
<body onLoad="simulateServerProcessing();">
<form action="mainpage.html" method="get" id="mainform">
<div id="textinput">
Type Some Text: <input type="text" name="textinput1" value=""/><br/>
<br/>
<input type="button" name="button1" value="Get Value" onClick="getValue()"/>
<input type="hidden" id="hiddenvalue" name="hiddenvalue" value="" />
</div>
<div id="textoutput">
</div>
</form>
</body>
</html>