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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass array object to a function 1

Status
Not open for further replies.

spiveygb

Programmer
Jun 24, 2003
27
0
0
US
I have two parallel arrays(siteID & floodForecastValue) that I would like to pass to the function passTime (see code below). However, when I mouse over the link I see that it is passing each element in both arrays separated by commas. Is there a way to pass the array itself rather than the contents of the array. Thanks in advance for the help.

Code:
document.write ("<td><a href='javascript:void passTime(" + siteID + "," + floodForecastValue + ")'>");
 

Yes - change your line to this:

Code:
document.write ("<td><a href='javascript:void passTime(siteID, floodForecastValue)'>");

Having them as part of a string forces JS to convert them to a string using the toString method of the Array object - which does what you've seen.

Hope this helps,
Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top