#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    13
    Rep Power
    0

    Checked is null or not an object


    Hi:
    I have a Cold Fusion form that has a radio box 'SearchType'. When I clicked commit, my form invoked a JS function 'checkNOFForm' to find out which radio was selected. For some reason inside that function, I keep getting the following error:

    Error: 'checked' is null or not an object <<<<========

    What does it mean, why it is complain it is not an object and how to resolve it?

    Here is my form:
    <form name="notonfileform" action="notonfileform.cfm" method="post" onSubmit="return checkNOFForm()">

    <input type="radio" name="Issue#i#SearchType" id="Issue#i#SearchType" value="UPC" <cfif IsDefined('FORM.Issue#i#SearchType') AND (Evaluate('FORM.Issue' & i & 'SearchType') EQ "UPC" )>checked</cfif> > UPC
    <input type="radio" name="Issue#i#SearchType" id="Issue#i#SearchType" value="PLU" <cfif IsDefined('FORM.Issue#i#SearchType') AND (Evaluate('FORM.Issue' & i & 'SearchType') EQ "PLU" )>checked</cfif> > PLU

    Here's my function;
    function checkNOFForm()
    {
    for (i=1; i<=form.NumIssues.value; i++)
    {
    whichField = document.getElementById('Issue' + i + 'SearchType');

    for (var j = 0; j < 3; j++) {
    if (whichField[j].checked) { <== this is the line of error
    alert(whichField[j].value);
    break;
    }
    }
    }


    Thanks for any help you can give...

    Newbie
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,243
    Rep Power
    967
    This is really a JavaScript question. It means that the value of "whichField[j]" is null. Since a null object has no "checked" property, calling "whichField[j].checked" causes an error.

IMN logo majestic logo threadwatch logo seochat tools logo