/    Sign up×
Community /Pin to ProfileBookmark

Send array to another page. How?

Anybody please tell me how can i use the array of javascript on other page (on action page) ?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Sirin86May 08.2008 — Unfortunately you can't share Javascript data over different page requests. You'll have to pass it somehow over GET or POST.
Copy linkTweet thisAlerts:
@toicontienMay 08.2008 — You could also use cookies.
Copy linkTweet thisAlerts:
@Logic_AliMay 08.2008 — Anybody please tell me how can i use the array of javascript on other page (on action page) ?[/quote]When you say 'action page' presumably you're submitting a form, in which case you can copy the array data into a hidden input, then reconstruct it in the destination document.
Copy linkTweet thisAlerts:
@JMRKERMay 09.2008 — I'm not sure if this will send a large array, but you didn't specify how big it is.

The example uses the same file, 'URLarray.html', but you should be able

to change to the correct file that will collect the passed information.

Just create a string of the elements separated by '&'

and append it to the URL with a '?='.

Code for: URLarrray.html
[code=php]
<html>
<head>
<title>Page Array Passage</title>
<script language="JavaScript" type="text/JavaScript">
function showloc() {
query = '' + this.location; //pulls the URL
query = query.substring((query.indexOf('=')) + 1); //removes everything to the left of the =
var arr = [];
arr = query.split(/&/);
var msg = 'Array information passed:<br>';
if (arr.length <= 1) { msg = 'No array information passed by:<br>'; }
document.getElementById('info').innerHTML = msg+arr.join('<br>');
}

window.onload=function(){showloc()} //needed to actually load the function
</script>
</head>
<body>
URLarray.html page called by:
<li><a href="URLarray.html">URLarray.html</a></li>
<br>
<li><a href="URLarray.html?=1&2&3&4&5&6&7&8&9">URLarray.html?=1&2&3&4&5&6&7&8&9</a></li>

<br>
<div id="info"></div>
</body>
</html>
[/code]

Once you get the URL string, push to another array or use 'arr' after split.
×

Success!

Help @jitendramca spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...