Pass and Read Parameters

[Total: 0    Average: 0/5]

This shows how to have a page submit data to itself.

Head Code:

<script>
var _c="";
var _l=document.location.toString().split("?"); /* now _l is the parameters */
/* document.write("_l="+_l+"<BR>"); */

var _m ="";
if(_l[1])
{
 _m = _l[1].split("&"); /* now _m is an array of all parameters */
}
if(_m[0]) _c="List of parameters:<BR>";
for (var i=0;i<_m.length;i++)
{
  _c+=_m[i]+"<BR>";
}
document.write(_c);
</script>

Body Code:

<script>
function doIt()
{
  document.location=document.location+"?"+document.tf.t1.value+"&"+document.tf.t2.value+"&"+document.tf.t3.value+"&"+document.tf.t4.value;
}
</script>
This form posts the paramters to this same page
<form name=tf>
<input type=text name=t1 value="one">
<input type=text name=t2 value="two">
<input type=text name=t3 value="three">
<input type=text name=t4 value="four">
<input type=button onclick="doIt()" value="Submit">
</form>

Times Viewed: 0

Leave a Reply

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