473,394 Members | 1,751 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,394 software developers and data experts.

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 2333
In article <11*********************@f14g2000cwb.googlegroups. com>,
Jo**********@gmail.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 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');

// 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.getElementById('bodyA');
var i=0, oTr, oTd, oChk, txt, let;

// Add the inputs and checkboxes
do {
oTr = document.createElement('tr');
let = numToAlpha(i);
txt = 'Input-1-' + let;
addToTr(oTr,document.createTextNode(txt));

oInp = document.createElement('input');
oInp.name = txt;
addToTr(oTr,oInp);

oChk = document.createElement('input');
oChk.type = 'checkbox'
oChk.name = 'Check-1-' + let;
oChk.onclick = function() {addInputsB(this)};
addToTr(oTr,oChk);

addToTr(oTr,document.createTextNode(chkTxt(let)));

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.nodeName)) {
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(document.createTextNode(txt));
oInp = document.createElement('input');
oInp.name = txt;
x.appendChild(oInp);
}
// Otherwise, put some text into it
} else {
x.appendChild(document.createTextNode(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.nodeName)) {t = t.parentNode;}
t.parentNode.removeChild(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.createElement('td');
oTd.appendChild(b);
a.appendChild(oTd);
}

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">Enter 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">(Integer 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.getElementById('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.nodeName)) {
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
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...
3
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
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...
4
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...
0
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...
0
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...
0
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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?
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
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...
0
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...
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...

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.