Results 1 to 4 of 4
Thread: Error undifined array
Jan 2, 2011, 06:31 #1
- Join Date
- Jan 2011
- 0 Post(s)
- 0 Thread(s)
Error undifined array
OK I am noobie to JS and have receive an error i do not understand of array undifined line 3.
This is simply apart of a script to validate a form I know this is going to turn out to be something rookie, but I am a bit lost, any help would be much appriciated.
/* define a function to be called later by an onclick comand saving the submit comand for a php script later */
// setsup an array with the required fields listed in it.
// this is the line I beleave that the error is refearing to.
var Element=new array("mytext","mytext1","mytext2");
// Sets up an array with to hold the required feilds that are empty.
var BadData=new array();
// Sets an integer so a for loop can read through the Elements array.
/* sets up an integer so the BadData array can be assigned empty required feilds from the Elements array. */
//runs through the arrays enering values into BadData array.
var myTextField = document.getElementById("Element[i]");
if(myTextField.value == "")
/* this part should display the fields that have not been field in*/
document.write("please fill in the following feilds");
for (x in BadData)
document.write(BadData[x] + "<br />");
//this is just for testing reasons.
alert("the form is valid");
I beleave the logich here should be sound but I have been wrong in the past. any help would be appriciated.