[Javascript] accessing javascript array value inside the select tag
Bill Marriott
bill.marriott at optusnet.com.au
Mon Dec 30 04:29:39 CST 2002
Hi
Something like this may be what you need to set the options dynamically ( if
that is what you are trying to do).
You will need to declare all the variables.
comboObj.options.length = 0;
var i;
for (i = 0; i < myarray.length; i++)
{
var pOption=document.createElement("OPTION");
pOption.value=myarray[i][0];
pOption.text=myarray[i][1];
comboObj.options.add(pOption);
}
Bill
----- Original Message -----
From: "Andrew Gibson" <andyg at ihug.co.nz>
To: <javascript at LaTech.edu>
Sent: Monday, December 30, 2002 2:26 PM
Subject: Re: [Javascript] accessing javascript array value inside the select
tag
> 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
>
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
More information about the Javascript
mailing list