Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing Arrayds

Status
Not open for further replies.

tempoman

Programmer
May 9, 2000
41
AU
Can someone please help me in passing the whole array from one page to the next after submission, and passing the whole array into a function. Any help will be grateful.<br><br>I have tried the input tag but this does not work, as it <br>complains about it not being a string.<br><br>Thanx<br><br>
 
If the array is small enough, you could pass the whole thing in the url, but another good way to do it would be create the array as a session variable, where you could use it in any page in the session. Instead of myarray[1], you'd use session.myarray[1]. (just be sure to have session management turned on in your Application.cfm template...
 
Thanx for the tip, DarkMan. The session variable works for passing the array to the next page, however I still have the problem of passing the array to a function, could you have a look at the following code and see how to pass the array? An error messages comes up that &quot;session&quot; is not found.<br><br>Thanx for all your help<br><br>&lt;cfset session.my=ArrayNew(1)&gt;<br>&lt;INPUT type=&quot;button&quot; value=&quot;Add to List&quot; onclick=&quot;f_store(document.history.command.value, session.my)&quot;&gt;<br><br>&lt;---Function ---&gt;<br>var index = 0;<br>var cmmnd = 1;<br>function f_store( sTR, history ) {<br>var i;<br>if( index &gt;= history.length ) {<br>for( i = 1; i &lt; history.length; i++ )<br>history[i-1] = history<i>;<br>index = history.length - 1;<br>}<br>history[ index ] = cmmnd + &quot;:&quot; + sTR;<br>++cmmnd;<br>++index;<br>document.history.command.value=&quot;&quot;;<br>}
 
hmmmm...<br><br>I think I can see what you're trying to do, but I'm not sure it's possible to pass a CF array to a javascript function....<br><br>I'm not that skilled with javascript, but my <b>guess</b> would be to turn the array into a list like<br><FONT FACE=monospace><b><br>&lt;cfoutput&gt;&lt;INPUT type=&quot;button&quot; value=&quot;Add to List&quot; onclick=&quot;f_store(document.history.command.value, #arraytolist(session.my,&quot;:&quot;)#)&quot;&gt;&lt;/cfoutput&gt;<br></b></font><br>using the colon or some other delimiter so not to confuse the js function, then turn that list back into an array in the javascript function (or work with it as a list there)..<br><br>I don't know enough about javascript to provide sample js code, and this is only a guess, but I hope it points you in the right direction...Let me know if this helps at all :)<br><br>DM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top