70 pts.
 Help a beginner! What is wrong with this VBScript code?
<html> <head> <%Dim ColorIndex(4),Colors(4),i %> </head> <body> <%ColorIndex(1)="Love":ColorIndex(2)="Jealous":ColorIndex(3)="Peace":ColorIndex(4)=+"Leading" Colors(1)="red":Colors(2)="yellow":Colors(3)="green":Colors(4)="blue"%> <form name ="myform"> <select name="mycolors" onchange ="GetIndex()"> <% for i=1 to 4 %> <option><%= Colors(i)%></option> <% Next %> </select> <script language ="vbscript"> sub getIndex() dim c c=myform.mycolors.selectedIndex msgbox "you selected "& "<%=Colors(c)%>" & " which means " & "<%=colorIndex(c)%>" 'c won't work here end sub </script></form> </body> </html>

Software/Hardware used:
ASKED: January 25, 2009  6:33 AM
UPDATED: January 27, 2009  7:26 PM

Answer Wiki:
I'm not a vbScript expert, but here's one way of doing it: <html> <head> <script language="vbscript"> sub getIndex(c) msgbox "you selected " & Colors(c) & " which means " & colorIndex(c) end sub </script> </head> <body> <script language="vbscript"> 'use base index of zero on arrays Dim ColorIndex(3),Colors(3),i ColorIndex(0)="Love" ColorIndex(1)="Jealous" ColorIndex(2)="Peace" ColorIndex(3)="Leading" Colors(0)="red" Colors(1)="yellow" Colors(2)="green" Colors(3)="blue" document.write("<form name=""myform"">") document.write("<select name=""mycolors"" onchange =""getIndex(myform.mycolors.SelectedIndex)"">") for i=0 to 3 document.write("<option>") document.write(Colors(i)) document.write("</option>") Next document.write("</select>") </script> </form> </body> </html>
Last Wiki Answer Submitted:  January 27, 2009  7:26 pm  by  Ledlincoln   1,620 pts.
All Answer Wiki Contributors:  Ledlincoln   1,620 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

What problems are you having ?
Are you getting errors ? what is the error message ?

 63,535 pts.