faqts : Computers : Programming : Languages : JavaScript : Forms

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 9 people (78%) answered Yes
Recently 2 of 3 people (67%) answered Yes

Entry

How can I get the data from the response to the browser from a submit()? Do I need a seperate function to receive it?

Dec 13th, 2000 13:14
Delf Burkhardt, Paul Keefe,


This solution works in newer Browsers
NS 4.5++, IE4++

Just create two html-files and name them step1.html, step2.html

Copy/paste, 
file 1 starts here :

<html>
<head>
	<title>submit</title>
</head>

<body>
<form action="step2.html">
<input type="hidden" value="topsecret" name="hiddenfield"><br>
<input type="text" value="" name="input_1" size="30"><br>
<input type="text" value="" name="input_2" size="30"><br>
<input type="text" value="" name="input_3" size="30"><br>
<input type="submit" value="submit">

</form>

</body>
</html>



<html>
<head>
	<title>Answer-Form</title>

<script language="JavaScript">
<!--
//
var esc = unescape(location.search);
var ss = esc.substring(1,esc.length);
var ok = false;
var myTitle=new Array();
var myContent= new Array();
var cur="";

if(ss.length!=0){
    ok=true; 
	ss= unescape(ss);
    str=ss.split('&');
	for (var i=0; i<str.length;i++){
		cur=str[i].split('=');
		if (cur.length==2){
			myTitle[i]=cur[0];
			myContent[i]=cur[1];		
		}
		else{
			myTitle[i]="";
			myContent[i]=cur[0];	
		}
	}
}

function getValues(){
	var str="";
	for(var i=0;i<myTitle.length;i++){
			str+=myTitle[i]+" = " +myContent[i]+"<br>";
	} 
	return str;
}

document.write(getValues());

//-->
</script>
</head>

<body>



</body>
</html>