Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] accessing javascript array value inside the select tag


  • From: javascript@xxxxxxxxxx (Andrew Gibson)
  • Subject: [Javascript] accessing javascript array value inside the select tag
  • Date: Mon, 30 Dec 2002 16:26:21 +1300

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