no properties / null or not an object error - Please help!

Discussion in 'JavaScript' started by Degas, Sep 11, 2006.

  1. #1
    Hi,

    I have an ASP page that needs to cross search on one of two recordset options, Products and Makers, so have duplicated the search form in home.asp and home.asp?func=1 so visitors just get one box to search and are redirected to the right page version to search from (ie home.asp for Products and home.asp?func=1 for Makers) on selecting the non default value from the dropdown menu with the two options, Products and Makers.

    I'm using onchange="funcRedirect();" for the listbox selectors as below

    <script type="text/javascript">

    function funcRedirect()
    {
    if(document.form1.combo1.options[document.form1.combo1.selectedIndex].text!="Products")
    {
    window.location="home.asp?func=1";
    }


    if(document.form2.combo3.options[document.form2.combo3.selectedIndex].text!="Makers")
    {
    window.location="home.asp";
    }
    }
    </script>

    This works fine for the first selection, the user selects Makers and is taken to home.asp?func=1. However, when Products is now selected in home.asp?func=1, they do not return to home.asp but get an error, either

    Error: 'document.form2.combo3.options is null or not an object' in IE or
    document.form2.combo3 has no properties in Firefox.

    I've been trying for a few hours to find an answer for this one - can anyone point me in the right direction? How do I set the properties for document.form2.combo3?

    Thanks for any help on this
    Jeremy
     
    Degas, Sep 11, 2006 IP
  2. VONRAT

    VONRAT Banned

    Messages:
    181
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try it this way

    function funcRedirect()
    {
    if(document.forms["form1"].combo1.options[document.forms["form1"].combo1.selectedIndex].text!="Products")
    {
    window.location="home.asp?func=1";
    }


    if(document.forms["form2"].combo3.options[document.forms["form2"].combo3.selectedIndex].text!="Makers")
    {
    window.location="home.asp";
    }
    }


    if it still does not work .. then perhaps something else is missing from your codes
     
    VONRAT, Sep 11, 2006 IP
  3. Degas

    Degas Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks VONRAT, but unfortunately that didn't work either, it gave me the same message as before.

    I'm not sure it likes being referenced from a func=1 address so will have another look at page naming
     
    Degas, Sep 12, 2006 IP