Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
TeamSite
TeamSite, LiveSite and OpenDeploy
passing args between2 html using JScript
Migrateduser
I was playing with passing arguments from one html to an other using simple Javascript. The invocation is done using a button in File1 which will open up File2 and should print the arguments which were passed to it.
Here are the file. File1 with Button calling File2
File 1:
[html]
Test Query Strings: Page 1
<script lang="javascript" type="text/javascript">
function testQueryStrings()
{
// change the window.location with your own.
window.location = "testjs2.html?name=alma&role=user";
}
</script>
[/html]
File 2:
[html]
Test Query Strings: Page 2
<script lang=”javascript” type=”text/javascript”>
var qrStr = window.location.search;
alert(qrStr);
var spQrStr = qrStr.substring(1);
alert(spQrStr);
var arrQrStr = new Array();
// splits each of pair
var arr = spQrStr.split('&');
for (var i=0;i// splits each of field-value pair
var index = arr
.indexOf('=');
var key = arr
.substring(0,index);
var val = arr
.substring(index+1);
// saves each of field-value pair in an array variable
arrQrStr[key] = val;
}
document.write("Hello World");
document.write("Name parameter: "+arrQrStr["name"]+". Role parameter: "+arrQrStr["role"]+"");
</script>
[/html]
I am not even getting my alerts. Any advice?
Thanks
Find more posts tagged with
Comments
There are no comments yet