473,657 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTML javascript checkbox issue

4 New Member
Here is a piece of html code

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

.
.
.
.

<input type="button" value="Publish" onClick="javasc ript:doPackages ubmit();">&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 "doPackageSubmi t" calls "getFormLis t".

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 2832
acoder
16,027 Recognized Expert Moderator MVP
Moved from Articles section.

You don't need to use getElementsByTa gName. Just use document.form.F ormListName to access the checkboxes.
May 16 '07 #2
narsibvl
4 New Member
I have tried that too with the same results.
May 16 '07 #3
narsibvl
4 New Member
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 Recognized Expert Moderator MVP
Does
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("package_information").FormListName
not work? If you do want to use getElementsByTa gName, 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
21163
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 value="cat">Cat <option value="dog">Dog ....
4
8397
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 in JavaScript/JScript and HTML/XML elements. Without trying to get famous :-) but thinking it would be interesting to others I decided to post the following summary: 1. Variable names in JavaScript/JScript
9
12542
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 Request.Form("CheckBox")(i)) > 0 then End If Next
11
3141
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 checked i want to set this hidden variable to 1 else 0... I am not getting what to write in Page_Load(object sender, System.EventArgs e) function to change the value of this html variable...
1
1276
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 issue is? Here is the url: http://67.62.217.33/test5 You will need to supply a valid zip, as it does a check for areas the insurance is available. You can use 23834 The issue I'm having is on the the next page there, intro-page2.asp, if you...
2
1810
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 Javascript to fill information in the table. Code looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
1
16951
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 examples I found on the web. Works in IE and mozilla. http://www.imaputz.com/cssStuff/bigFourVersion.html
5
1190
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 to the value of "cond", as well as "addncomment101. Also, I need to use some kind of array to track which cells of the table have been filled. I'd like to use JavaScript to do this, but I'm a JS newbie so I'm stuck. Ultimately, these variables will be...
1
1579
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 variable so it can return ALL the data is not completeing the variable processing of the HTML FILE. For example the values that have $results in them are just displaying $results instead of the actual database information. Does anyone know of...
0
8399
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6169
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.