473,788 Members | 2,743 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]
------------------------------**-------------------------
NOTE:THE RESULTS BELOW IS AFTER 2 IS ENTERED INTO THE input ABOVE
________
input1A |_______| [] "check here to add input2A and input3A"
________
input1B |_______| [] "check here to add input2B and input3B"
[submit] [reset]
------------------------------**-------------------------
NOTE: THE RESULTS BELOW WHAT HAPPENS WHEN THE FIRST CHECKBOX ABOVE IS
CLICKED
________ ________ ________
input1A |_______| [] input2A |_______| input3A |_______|
________
input1B |_______| [] "check here to add input2B and input3B"
[submit] [reset]

Jul 23 '05 #1
5 2376
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.

--
--
~kaeli~
Press any key...NO, NO, NO, NOT THAT ONE!!!!!!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

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.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title> Add inputs </title>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
</head>
<body>

<style type="text/css">
table { /* border-collapse: collapse; */ border: 1px solid blue;
padding: 1px 1 1 1;}
..tip {font-size: 90%; color: #666633;}
</style>
<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();
return;
}

// Delete the body containing the first input
delBody(t);

// 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
delKids(x);

// 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;
}

</script>

<form action="">
<table border="1">
<tbody>
<tr>
<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);
">
<br>
<span class="tip">(In teger greater than 1)</span>
</td>
</tr>
</tbody>
<tbody id="bodyA">
</tbody>
<tbody>
<tr>
<td colspan="4">
<input type="reset">
<input type="submit">
</td>
</tr>
</tbody>
</table>
</form>

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

</body>
</html>
Jul 23 '05 #4
Thanks man, check your email I sent a personal message.

Jul 23 '05 #5
Fred,

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

4
2151
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...
3
14728
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
3
3986
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...
4
7267
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:
0
3518
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...
0
4668
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...
0
1348
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...
1
6020
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...
0
9656
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
9498
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
10370
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
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
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
6750
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
5402
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...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
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 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.