Form Posts Data To Itself

[Total: 0    Average: 0/5]

This code will allow you to post form data to itself.

Init Code:

readParms();

Body Code:

<HR>
This form is for your first page<BR>
<!--
  -- You will need to change the 'thispage.html' to be the name you save
  -- this file as.
  -->
<form action="thispage.html" method=GET>
<input type=text name=t1 value="starting value + & that">
<input type=submit name=t2 value="Submit This Data">
</form>
<BR><HR><BR>
This form will determine what was posted and use that information:<BR>
<form name=f1>
<input type=text name=t1 value="other value">
<input type=text name=t2 value="second other">
</form>
<script>
function readParms()
{
  var _docLoc=document.location.toString();
  var t1="";
  var t2="";
  if(_docLoc.indexOf("?")!=-1)
  {
    var _parmString=_docLoc.substr(_docLoc.indexOf("?"),_docLoc.length);
	/* look for 2 parameters - assume they are there if you get here */
	var _parms=_parmString.split("&");
	t1=_parms[0].split("=")[1];
	while(t1.indexOf("+")!=-1)
	{
	  var _t=t1.indexOf("+");
	  var _tL=t1.length;
	  t1=t1.substr(0,_t)+" "+t1.substr(_t+1,_tL);
	}
	t1=unescape(t1);
	t2=_parms[1].split("=")[1];
	while(t2.indexOf("+")!=-1)
	{
	  var _t=t2.indexOf("+");
	  var _tL=t2.length;
	  t2=t2.substr(0,_t)+" "+t2.substr(_t+1,_tL);
	}
	t2=unescape(t2);
  }
  document.f1.t1.value=t1;
  document.f1.t2.value=t2;
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *