document.form.ckbox is null or not an object

how can i fix this?
please help...i have 2 hours to fix it and i have no idea how:(
<script language="JavaScript">
function get_check_value()
{
      var c_value = "";
 
      for (var i=0; i < document.form.ckbox.length; i++)
      {
            if (document.form.ckbox[i].checked)
            {
                  c_value = c_value + document.form.ckbox[i].value + "\n";
            }
      }
 
      if ( c_value != "" )
      {
            getcustomer ( c_value );
      }
 
}
 
function getcustomer ( customer )
{
      // do something with the customer
      // then call return
}
</script>
 
 
<form action="" method="">
...
response.write "<p><input type=""checkbox"" name=""menu"" value='" & rstemp1("id") & "' >" & rstemp1("subcat") & "</p>"
...
</form>
 
<A href="#" onclick="get_check_value();">find values</A>

Open in new window

Forrest_GumpAsked:
Who is Participating?
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
The name is menu and not ckbox

Here is a safer script
<script language="JavaScript">
function get_check_value() {
  var theForm = document.forms[0]; // assuming first form and that elements have been wrapped in a form tag
  var c_value = "";
  if (theForm.menu.length) { // there may be only one
    for (var i=0; i < theForm.menu.length; i++) {
      if (theForm.menu[i].checked) c_value += theForm.menu[i].value+"\n";
    }
  }
  else if (theForm.menu.checked) c_value = theForm.menu.value+"\n"; // assuming getcustomer needs the trailing \n
  if (c_value != "") getcustomer(c_value);
  return false; // cancel the href 
}
 
function getcustomer ( customer )
{
      // do something with the customer
      // then call return
}
</script>
 
 
<form action="" method="">
...
response.write "<p><input type=""checkbox"" name=""menu"" value='" & rstemp1("id") & "' >" & rstemp1("subcat") & "</p>"
...
</form>
 
<A href="#" onclick="return get_check_value(); ">find values</A>
 
NOTE THE RETURN on the click

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
do you generate form controls first clearly? lot of syntax errors on your form code
0
 
Michel PlungjanIT ExpertCommented:
What syntax errors???

Missing values for method and action could just be because it is an example

0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Forrest_GumpAuthor Commented:
document.form.ingrid is null or not an object:(
<form>
<%
...
response.write "<input type=""checkbox"" name=""ingrid"" value='" & rstemp1("id") & "' >" & rstemp1("subcat") & "<br>"
...
%>
 
<A href="#" onClick="showingr(get_check_value()); return false">find values</A>
</form>
 
 
 
.......
 
 
function get_check_value() {
  var c_value = "";
  for (var i=0; i < document.form.ingrid.length; i++) {
    if (document.form.ingrid[i].checked) {
      c_value = c_value + document.form.ingrid[i].value + "\n";
    }
  }
  return c_value; // may be empty
}
 
function showingr(customers) {
  if (customers=="") return; // leave the function
 
{ 
xmlHttpSel2=GetXmlHttpObject();
if (xmlHttpSel2==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getcustomer.asp";
url=url+"?ingr="+customers;
url=url+"&sid="+Math.random();
xmlHttpSel2.onreadystatechange=ingrChanged;
xmlHttpSel2.open("GET",url,true);
xmlHttpSel2.send(null);
}
 
function ingrChanged() 
{ 
if (xmlHttpSel2.readyState==4)
{ 
document.getElementById("txtHint").value=xmlHttpSel2.responseText;
}
}
 
 
}

Open in new window

0
 
Michel PlungjanConnect With a Mentor IT ExpertCommented:
document.forms[0].ingrid !!!!!! if it is the FIRST form, change [0] to [1] for the second form and so on

And make sure your checkboxes are wrapped in a form tag

<form>
<%
...
response.write "<input type=""checkbox"" name=""ingrid"" value='" & rstemp1("id") & "' >" & rstemp1("subcat") & "<br>"
...
%>
</form>

I will not be online for a few hours now
0
 
Forrest_GumpAuthor Commented:
http://ilmc.brinkster.net/cpp/web/getcustomer.asp
that is not doing anything:(
i got no error but i am clicking on the
      <p><input type="CHECKBOX" name="ingrid" value="3"> ...and The Other</p>
and that is not going anywhere...
0
 
Forrest_GumpAuthor Commented:
dear mplungjan,
you soved the original question problem so i am closing this question and thakyou for that.
but the origianl problem was not solved so please help me here:
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_23513718.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.