473,726 Members | 2,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A nested dynamic checkbox inside my dynamic form.

I am having a problem with the last results. I can't seem to be able to
get the input2A and input3A to appear. I don't seem to have a problem
with the show and hide after a number is entered and submitted. If
anyone can answer my problem I will be greatly appreciated with a
prize. I actually have submitted it more than once and I haven't had
anyone been able to answer it yet.
enter # of input0A |_______|

[submit] [reset]
input1A |_______| [] "check here to add input2A and input3A"
input1B |_______| [] "check here to add input2B and input3B"
[submit] [reset]
________ ________ ________
input1A |_______| [] input2A |_______| input3A |_______|
input1B |_______| [] "check here to add input2B and input3B"
[submit] [reset]

Jul 23 '05 #1
5 2372
In article <11************ *********@f14g2 000cwb.googlegr oups.com>,
Jo**********@gm ail.com enlightened us with...
I am having a problem with the last results.

Post testable code or a URL.

Press any key...NO, NO, NO, NOT THAT ONE!!!!!!

Jul 23 '05 #2
I don't have any that works.

Jul 23 '05 #3
pizzy wrote:
I don't have any that works.

Now you do. Put in any value you like, it will keep adding 'em.

<title> Add inputs </title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">

<style type="text/css">
table { /* border-collapse: collapse; */ border: 1px solid blue;
padding: 1px 1 1 1;}
..tip {font-size: 90%; color: #666633;}
<script type="text/javascript">

// Create an array of the letters of the alphabet
var alpha = 'ABCDEFGHIJKLMN OPQRSTUVWXYZ'.s plit('');

// Add first set of inputs and checkbox
function addInputsA(f,t) {
// Clean and validate input
var n = t.value.replace (/\s+/g,'');
if (/\D+/.test(n) || 1 > n || '' == n) {
alert('Please enter an integer greater than 0');
if (t.focus) t.focus();

// Delete the body containing the first input

// Setup variables
var bA = document.getEle mentById('bodyA ');
var i=0, oTr, oTd, oChk, txt, let;

// Add the inputs and checkboxes
do {
oTr = document.create Element('tr');
let = numToAlpha(i);
txt = 'Input-1-' + let;
addToTr(oTr,doc ument.createTex tNode(txt));

oInp = document.create Element('input' );
oInp.name = txt;
addToTr(oTr,oIn p);

oChk = document.create Element('input' );
oChk.type = 'checkbox'
oChk.name = 'Check-1-' + let;
oChk.onclick = function() {addInputsB(thi s)};
addToTr(oTr,oCh k);

addToTr(oTr,doc ument.createTex tNode(chkTxt(le t)));

bA.appendChild( oTr);

} while (++i < n)

// Add second set of inputs
function addInputsB(y){
var x = y, oInp, txt;
var nBit = x.name.split('-');
// Go up to parent td
while (!/td/i.test(x.nodeNa me)) {
x = x.parentNode;
// Go to next td
x = x.nextSibling;
// Remove its content

// If checkbox checked, put inputs into it
if (y.checked) {
for (var j=2; j<4; j++) {
txt = 'Input-' + j + '-' + nBit[2];
x.appendChild(d ocument.createT extNode(txt));
oInp = document.create Element('input' );
oInp.name = txt;
x.appendChild(o Inp);
// Otherwise, put some text into it
} else {
x.appendChild(d ocument.createT extNode(chkTxt( nBit[2])));

// Returns a string with value of 'a' appended
function chkTxt(a){
return 'Click to add inputs 2 & 3 ' + a;

// Deletes a tbody given any element inside the tbody to delete
function delBody(t) {
while ( !/tbody/i.test(t.nodeNa me)) {t = t.parentNode;}
t.parentNode.re moveChild(t);

// Removes all child nodes of given element
function delKids(n) {
while (n.firstChild) {n.removeChild( n.firstChild)}

// Given a tr, append b to new cell, append cell to tr
function addToTr(a,b){
var oTd = document.create Element('td');
oTd.appendChild (b);
a.appendChild(o Td);

function numToAlpha(n){
var t='';
while (n > 0) {
t = alpha[n%26] + t;
n = Math.floor(n/26-1);
return (0 > n)? t : alpha[n] + t;


<form action="">
<table border="1">
<td colspan="2">Ent er number of inputs:
<input type="text" size="5" name="numInputs ">
<input type="button" value="Add inputs" onclick="
addInputsA(this .form,this.form .numInputs);
<span class="tip">(In teger greater than 1)</span>
<tbody id="bodyA">
<td colspan="4">
<input type="reset">
<input type="submit">

<!-- test harness for the number-to-alpha-index thing -->
<input type="text" size="10" onblur="
var o = document.getEle mentById('xx');
var n = +this.value, t='', m;
while (n > 0) {
t = alpha[n%26] + t;
n = Math.floor(n/26-1);
(0 > n)? t=t : t = alpha[n] + t;
o.innerHTML = t;

<span id="xx"></span>

Jul 23 '05 #4
Thanks man, check your email I sent a personal message.

Jul 23 '05 #5

Can you put the following into laymens terms?

while (!/td/i.test(x.nodeNa me)) {
x = x.parentNode;

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
by: DonRex | last post by:
Hello all! I couldn't find a web application-newsgroup for ASP.NET, so I'm sorry if this is the wrong forum! Synopsis: In my webform I have 3 nested repeaters: rpWeeks ----- rpTime
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
by: jedimasta | last post by:
Good evening all, I'm a relatively new to javascript, but I've been working with ColdFusion and PHP for years so I'm not necessarily ignorant, just stuck and frustrated. Using ColdFusion I'm using an include to pull in form elements (text fields, checkboxes, etc...) multiple times on a single page. The included page does not have a form tag of it's own, but the root page has uniquely named forms for validation. Imagine it like this:
by: mutt1170 | last post by:
I have a checkbox list nested inside a gridview. The gridview pulls its data from an objectdatasource and lists countries. The nested checkbox list is databound to another object datasource and lists the regions for each country. The checkboxlist has autopostback set to true and I want to perform an action based on whether or not each checkbox is selected. I am having trouble retrieving the nested checkboxlist to access the selected...
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box and also get the datakey (in my case personid) of the the rows selected. Please point me in the right direction. This is what i have so far but i have problem accessing the child gridview in the button click event Cheers, Shilpa. <asp:GridView...
by: =?Utf-8?B?SWRlcm9ja3M=?= | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in different event...
by: iderocks | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and when I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in a different event...
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...
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...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.