Solved

document.form.ckbox is null or not an object

Posted on 2008-06-24
7
228 Views
Last Modified: 2008-06-25
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

0
Comment
Question by:Forrest_Gump
  • 3
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 21862911
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
 
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 21862944
do you generate form controls first clearly? lot of syntax errors on your form code
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 21863092
What syntax errors???

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

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Forrest_Gump
ID: 21863346
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
 
LVL 75

Assisted Solution

by:Michel Plungjan
Michel Plungjan earned 500 total points
ID: 21863394
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
 

Author Comment

by:Forrest_Gump
ID: 21863567
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
 

Author Comment

by:Forrest_Gump
ID: 21863773
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can display objects ? 3 20
servlet doXXX methods 3 34
Angular - "nest" service calls? 18 21
Materializecss - Different Behaviors in Browser's 1 17
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now