Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
passing args between2 html using JScript
Bhargav Coca
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
Bhargav Coca
Never mind folks. My bad, its bad interpretation of double quotes by my browser.
This thing works well.
Thank You
Ticket_2709 (15).pdf
ticket_PageNew.rptdesign