Solved

document.form.ckbox is null or not an object

Posted on 2008-06-24
7
224 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

705 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

20 Experts available now in Live!

Get 1:1 Help Now