...

View Full Version : javascript/function/wddx recordset problem



bill267
12-12-2002, 06:02 AM
Any help will be greatly appreciated...

I am having a problem with a javascript function that dynamically populates a select box based on the user selection of another select box.

I call the function using the onchange event for the 1st select box. I pass the value of the user selection after appending the word "type" to it.

The function is supposed to read a wddx recordset that has been deserialized for javascript. I know this works and I'll explain why after I show my function code.

<SCRIPT LANGUAGE="JavaScript">
function choosenext(thetype) {
alert(thetype);
document.firstTry.DynSelect.length=0;
for (var RowNum=0; RowNum<thetype.model.length; RowNum++) {
NewOpt=new Option;
NewOpt.value=thetype.make[RowNum];
NewOpt.text=thetype.model[RowNum];
document.firstTry.DynSelect.options[RowNum]=NewOpt;
}
}

</SCRIPT>


The alert box is just confirming to me that the value of thetype is the value I expected and it is. However, I get an error when I try to determine the length of thetype.model. The error is "model.length is null or not an object". If I put a number there, then I get the error on thetype.make[RowNum].

In the following version of the code, I replace the thetype.model.length with 7 and replace thetype with "type3". Type3 is one of many possible deserialized wddx recordsets. With these values hard-coded, the second select box is created properly.

<SCRIPT LANGUAGE="JavaScript">
function choosenext(thetype) {
alert(thetype);
document.firstTry.DynSelect.length=0;
for (var RowNum=0; RowNum<7; RowNum++) {
NewOpt=new Option;
NewOpt.value=type3.make[RowNum];
NewOpt.text=type3.model[RowNum];
document.firstTry.DynSelect.options[RowNum]=NewOpt;
}
}

</SCRIPT>

It would seem that my variable thetype is not being interpreted properly. The alert box indicates that it is the proper value, so I'm at a loss. I'm missing something, but my brain is too small to figure it out. Thanks for taking the time to read this message.

Bill

Roelf
12-12-2002, 07:55 AM
i think the problem is in the "thetype" variable, if you can explain or show us what it contains, maybe we can help you, with the rest of your code seems nothing wrong

glenngv
12-12-2002, 09:39 AM
when you alert(thetype), it should alert [object].
Im suspecting that you are passing the parameter as a string not an object.

if type3 is an object you should pass it without quotes:

choosenext(type3)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum