473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HTML javascript checkbox issue

Here is a piece of html code

[HTML]<form name="package_information" id="package_information" method="post" enctype="multipart/form-data""& lt;"
<tr>
<td><input type="checkbox" name="FormListName" value="31" />Adobe client-server form</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="32" />Adobe XDP form</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="29" />Dispute Form (pff)</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="30" />SSA Form SSA-L996 (pff)</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="22" />Tax form 1040a (1)</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="23" />Tax form 1040a (2)</td>
</tr>
<tr>
<td><input type="checkbox" name="FormListName" value="28" />Tax form 1040a User Verification Required</td>
</tr>

.
.
.
.

<input type="button" value="Publish" onClick="javascript:doPackagesubmit();">&nbsp;
</form>
[/HTML]

Here are the relevent javascript functions

Expand|Select|Wrap|Line Numbers
  1. function getFormList()
  2. {
  3.         var formListStr = null;
  4.         var firstIteration = true;
  5.         var formList = document.getElementById("package_information").getElementsByTagName("FormListName");
  6.         if (eval(formList))
  7.         {
  8.             if (eval(formList.length != "undefined"))
  9.             {
  10.                 if (formList.length == 0)
  11.                 {
  12.                      alert("Need to select atleast one form for a explicit package" );
  13.                      switchPage('page4'); switchnav('nav4');
  14.                 }     
  15.  
  16.                 for (i = 0 ; i < formList.length; i++)
  17.                 {
  18.                     if ((formList[i].checked))
  19.                     {
  20.                         if (firstIteration)
  21.                         {
  22.                             formListStr = formListStr+formList[i].value+","
  23.                             firstIteration = false;
  24.                         }else
  25.                         {
  26.                             formListStr = formListStr+formList[i].value;
  27.                         }    
  28.                     }
  29.                 }
  30.             }else
  31.             {
  32.                 if (formList.checked == true)
  33.                 {
  34.                     alert("Only one checkbox is checked");
  35.                 }else
  36.                 {
  37.                     alert("formList is not checked");
  38.                 }
  39.             }    
  40.         }else
  41.         {
  42.             alert("forms list does not exist");
  43.         }    
  44.  
  45.         return formListStr;
  46. }

Javascript function "doPackageSubmit" calls "getFormList".

Now here is my problem, irrepective of how many of the checkboxes i check i always get the message "Need to select atleast one form for a explicit package". What is that ?
May 16 '07 #1
4 2816
acoder
16,027 Expert Mod 8TB
Moved from Articles section.

You don't need to use getElementsByTagName. Just use document.form.FormListName to access the checkboxes.
May 16 '07 #2
I have tried that too with the same results.
May 16 '07 #3
Dunno if this makes a difference but the checkbox buttons are created at runtime. (This is part of jsp code).
May 16 '07 #4
acoder
16,027 Expert Mod 8TB
Does
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("package_information").FormListName
not work? If you do want to use getElementsByTagName, then use "input" (the tag name) instead and then check for the type (checkbox). See link
May 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RC | last post by:
Order for PHP get the array from a HTML form checkbox or select tag. The HTML name MUST with . For example: <form methos=POST action="myfile.php"> <select name="pets" multiple> <option...
4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
9
by: Craig Andrews | last post by:
Hello, How do I access HTML CheckBoxs in the codebehind section of an ASP.NET program? In the old Interdev days one would: For i = 1 to Request.Form("CheckBox").Count if...
11
by: saurabh | last post by:
Can anybody tell me how to change the value of an html control from the c#.... eg i hv one asp.net radio button control and one html hidden variable... so on page load in case the radio button is...
1
by: dirt29 | last post by:
I'm builiding an online insurance application, where people input thier data, and it gives them rates, then lets them apply. I was wondering if someone could take a look and maybe tell me what the...
2
by: sarafat | last post by:
greetings people I am new to Ajax and javascript, yet i have little time to learn it all. Question is: i am using javascript to create my DOM Table and AJAX that returns a DataSet to my...
1
by: since | last post by:
I figured I would post my solution to the following. Resizable column tables. Search and replace values in a table. (IE only) Scrollable tables. Sortable tables. It is based on a lot...
5
by: phub11 | last post by:
Hi all, Below is a simple script (adapted from http://forums.asp.net/p/1037158/1453597.aspx) which allows me to drop clones of an object into a table; however, I'd like to have (value="101") set...
1
by: arggg | last post by:
I have an external html that is a form. the Values of the form elements have <?= $results ?> type information however with file_get_contents in the main php file that then stores the contents to a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.