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!

How do I pass a multidimensional array (ASP) to a function in JS ? 2

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
<script language=&quot;javascript&quot;>
<!--
function filterPic(eenType[][]) {

}
-->
</script>
</head>

<body>
<% rstypes.movefirst() %>

<A HREF=&quot;#&quot; onclick=&quot;filterPic(<% TypeProjecten()() %>)&quot;> <% response.write(rsTypes.Fields.Item(&quot;Tnaam&quot;).Value) %> </A>

What am I doing wrong ='(
It says the subscript is out of reach.

Thx :)
 
You cant acess ASP(server side script) with client side script, but you can send the information corectly.

________
George, M
 
What i mean is
<%
'this works for numerica values, for string values it needs to have some modifications

dim x(10)
for i=1 to 10
x(i)=i
next
aspArray=Join(x,&quot;,&quot;)
'aspArray will look something like this 1,2,3,4,5..,10
%>
<script language=javascript>
var jsArray=new Array(<%=aspArray%>)
</script>

and you can acess jsArray from 0 to jsArray.length-1 jsArray[index]

________
George, M
 
it's a bit a pain in the ass :'(
Guess it'll have to work like that then .

Thanks a zillion :) ur a lifesaver
 
I can't get it done with a multidimensional array though :s

jsTypeProjecten = new Array( <% TypeProjecten %>);

Says the types are different :'(
I was able to get all the numbers in different array.. but they'll be a real pain to address.
'for i = 0 to Ubound(TypeProjecten)
' response.write(&quot; jsType&quot; + Cstr(i) + &quot; = new Array(&quot;)
' for j = 0 to Ubound(TypeProjecten(i)) - 1
' if j = Ubound(TypeProjecten(i)) - 1 Then
' response.write(TypeProjecten(i)(j))
' else
' response.write(TypeProjecten(i)(j) + &quot;,&quot;)
' end if
' next
' response.write(&quot;);&quot; + vbCRLF)
'next
'response.write(&quot;jsTypeProjecten = new Array(&quot; + Cstr(Ubound(TypeProjecten)) + &quot;);&quot;)
'response.write(&quot;jsTypeProjecten[1] = jsType()&quot;)

Gives as output

jsType0 = new Array();
jsType1 = new Array(6,5);
jsType2 = new Array(7);
jsType3 = new Array(8);

But I want to be able to write a function like
function filterPic(type) {
for (i=0;i < type;i++) {
parent.mainFrame.document.images.FPT_P type.src = &quot;affli3t.jpg&quot;;
}
}
I have no idea how to make it so that FPT_P type.src changes like FPT_P5
and I want to call this function with something like
<A HREF=&quot;#&quot; onclick=&quot;filterPic(jsType<%=(rsTypes.Fields.Item(&quot;TypeID&quot;).Value)%>)&quot;> <% response.write(rsTypes.Fields.Item(&quot;Tnaam&quot;).Value) %> </A>

Aren't there any better ways :'(
All I need to do is have the numbers from the pictures that need to be changed in an array.
When clicked on the link the pictures with that number need changing ...
 
Yay thanks a lot :)
I guess i'll address the problem of addressing pictures by placing them in an array. Saw something about that somwhere :)
I'm not exactly a JS expert lol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top