?
Solved

document.form.ckbox is null or not an object

Posted on 2008-06-24
7
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 2000 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

771 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