[Javascript] accessing javascript array value inside the select tag
Andrew Gibson
andyg at ihug.co.nz
Sun Dec 29 21:26:21 CST 2002
I think probably you'd put those arrays in with a server side script
Something like:
<option value="<%=collegeId(i)%>">"<%=collegeName(i)%>"</option>
If you needed to access the collegeName(i) you could always go
<option value="<%=collegeId(i)&"|"&collegeName(i)%>">
Then the value is, say, 1|My college
and you can parse out the id etc with Javascript.
> My question was confusing. It's like this :
> I have a script like this :
>
> <SCRIPT LANGUAGE="JavaScript">
> <!--
> var collegeName = new Array('NMAMIT','NIT','NIIT');
> var collegeId = new Array('001','002','003','004');
> //-->
> </SCRIPT>
>
> now i have a select tag in which i want to have
> <option value=collegeId[i]>collegeName[i]</option>
> where i is the index of the array
More information about the Javascript
mailing list