473,379 Members | 1,170 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,379 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 2815
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.