I am trying to get this to work. I am trying to dynamically create a test from an array of questions. I am using a external script, because otherwise, I would dynamically have to recreate all of the script, because the first page that loads is destroyed by the dynamically created 2nd page. Also, the problem im running into is getting the getObj to work from a specific form. I want it to be in Javascript/HTML. Here are the 2 files involved:
Please see the errors in comments:
[code=php]
function checkTest(myForm)
{
for(x=0; x<questions; x++)
{
//theSearch=”quest” + x
//alert(“quest1”);
//alert(myForm.quest1.value);
//alert(getObj(“myForm.quest1”));
//alert(getObj(“myForm.quest1”).value);
theQuest=getObj(myForm.quest + x);
alert(theQuest.value); //error here?????????
if(theQuest.value == “”) //want to use getObj if possible
{
alert(“Fill all”);
}
}
}
function getObj(name)
{
//alert(name);
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style; //should be good, but i get error here…………….
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
}