Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript/function/wddx recordset problem

    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Zwolle, The Netherlands
    Posts
    1,120
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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
    I am the luckiest man in the world

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,946
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •