Top » JAVASCRIPTS » PASSING PARAMETERS HTML TO HTML
Javascript Category --> DOCUMENT  DESCRIPTION - RUN CODE


This is the Code View for Passing Parameters HTML to HTML :

Go Get The Code Now - See The Code Run

<html>
<head>
<!--
This file retrieved from the JS-Examples archives
http://www.js-examples.com
1000s of free ready to use scripts, tutorials, forums.
Author: JS-X - http://www.js-x.com/
-->

</head>
<body>
<form name=exf1>
P1 = <input type=text name=t1 value="parm1"><BR>
P2 = <input type=text name=t2 value="parm2"><BR>
</form>
<a href="javascript:doIt()">pass params</a>
<script type=text/javascript>
function doIt() {
  var _t1 = escape(document.exf1.t1.value);
  var _t2 = escape(document.exf1.t2.value);
  var _x = document.location.toString().indexOf("?") == -1?"?":"&";
  // if you want to use this more that just once in a row:
  //  you need to change = document.location + .. to be:
  //  = document.location.toString().substr(0,document.location.toString().indexOf("?")) + ...
  //  this will remove the parameters passed to it before adding the new parameters..
  document.location = document.location + _x + "t1="+_t1+"&t2="+_t2;
}
var _p,_q,_n;
_p = document.location.toString();
_q = _p.indexOf("t1=");
if (_q != -1 ) {
  _n = _p.substr(_q+3,_p.length);
  if (_n.indexOf("&") != -1) {
    _n = _n.substr(0,_n.indexOf("&"));
  }
  document.exf1.t1.value = unescape(_n);
}
_p = document.location.toString();
_q = _p.indexOf("t2=");
if (_q != -1 ) {
  _n = _p.substr(_q+3,_p.length);
  if (_n.indexOf("&") != -1) {
    _n = _n.substr(0,_n.indexOf("&"));
  }
  document.exf1.t2.value = unescape(_n);
}
</script>
<BR><center><a href='http://www.js-examples.com'>JS-Examples.com</a></center>
</body>
</html>



87%
Total Votes3
Avg Rating4.3333

Author Name:JS-X   [web site
Date Submitted:May, 2000
Times Viewed:21,702
Runs in IE:Yes
Runs in NS:Yes
Category List:
DOCUMENT
Key Words:
passing parameters