I have a very large script and I need to connect a few pieces of java script that I have figured out to put it all together. So here’s my sudo code with comments about what I want to do. if you can change any of it into actual code it would be great. Thanks in advance!
[code=php]//make a new array by hand not with a loop that contains 106 or so elements with each element containing three associated values here I just want to know how to make the array please do not waste your time writing 106 entry’s I can do that
new array veglookup()
{
veglookup[0] (name=”apple”, element=39 , vegetable=”NO”)
veglookup[1] (name=”banana”, element=42 , vegetable=”NO”)
veglookup[2] (name=”ketchup”, element=40 , vegetable=”YES”)
.//more elements here
.//and yet more
veglookup[106] (name=”my brain”, element=150 , vegetable=”MABEY”)
}
//choose a random element from the array
var rande= Math.floor(Math.random() * veglookup.legnth);
//retrieve the value of element to use in some document.form.element[i] statements later
var i= veglookup[rande].element.value
//retrieve the name to use to set new values for vegtable based on other stuff going on inside the if statement
var vegname=veglookup[rande].name.value
if (vegname==”my brain”)
{
//set values within the array
veglookup[rande].vegtable.value=”YES”
}
//get the info from a if and or not exc.
if (veglookup[rande].vegtable.value==”YES”)
{
alert(” “+vegname+” is a vegetable!”)
//use the element #in a document.form.element[i]statement
document.form.element[i].value=((document.form.element[i].value)*1)-1
}
Thank’s again!