473,785 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Revised: A form -to- dynamic form -to- dynamic checkboxes

PROBLEM: I CAN'T GET THE LAST RESUTS TO WORK CORRECTLY. I WOULD
PROVIDE THE CODE (AND WILL IF REQUESTED).
BUT IN MY OWN WORDS I AM TRYING TO HAVE THE FIRST FORM
DYNAMICALLY CREATE INPUT BOXES BASED ON THE NUMBER
ENTERED. THEN ON THE SECOND FORM (WHICH IS CREATED BY
THE FIRST FORM CALLING A FUNCTION) I WANT THE USER TO BE
ABLE TO CLICK ON ONE OF THE CHECKBOXES AND SEE MORE
INPUT BOXES APPEAR. HAS ANYONE DONE SOMETHING LIKE THIS?
IF SO, WHAT IS THE BEST APPROACH FOR ME TO GET THIS DONE?
________
enter # of input0A |_______| [submit] [reset]
------------------------------*-------------------------
READ: THE FORM 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]
------------------------------*-------------------------
READ: THE FORM BELOW IS THE RESULTS OF CLICKING THE FIRST
CHECKBOX ABOVE
________ ________ ________
input1A |_______| [] input2A |_______| input3A |_______|
________
input1B |_______| [] check here to add input2B and input3B
[submit] [reset]

Jul 23 '05 #1
7 1952

pizzy wrote:
PROBLEM: I CAN'T GET THE LAST RESUTS TO WORK CORRECTLY. I WOULD
PROVIDE THE CODE (AND WILL IF REQUESTED).
BUT IN MY OWN WORDS I AM TRYING TO HAVE THE FIRST FORM
DYNAMICALLY CREATE INPUT BOXES BASED ON THE NUMBER
ENTERED. THEN ON THE SECOND FORM (WHICH IS CREATED BY
THE FIRST FORM CALLING A FUNCTION) I WANT THE USER TO BE
ABLE TO CLICK ON ONE OF THE CHECKBOXES AND SEE MORE
INPUT BOXES APPEAR. HAS ANYONE DONE SOMETHING LIKE THIS?
IF SO, WHAT IS THE BEST APPROACH FOR ME TO GET THIS DONE?
________
enter # of input0A |_______| [submit] [reset]
------------------------------*-------------------------
READ: THE FORM 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]
------------------------------*-------------------------
READ: THE FORM BELOW IS THE RESULTS OF CLICKING THE FIRST
CHECKBOX ABOVE
________ ________ ________
input1A |_______| [] input2A |_______| input3A |_______|
________
input1B |_______| [] check here to add input2B and input3B


[submit] [reset]


Jul 23 '05 #2
pizzy wrote:
PROBLEM: I CAN'T GET THE LAST RESUTS TO WORK CORRECTLY. I WOULD
PROVIDE THE CODE (AND WILL IF REQUESTED).
BUT IN MY OWN WORDS I AM TRYING TO HAVE THE FIRST FORM
DYNAMICALLY CREATE INPUT BOXES BASED ON THE NUMBER
ENTERED. THEN ON THE SECOND FORM (WHICH IS CREATED BY
THE FIRST FORM CALLING A FUNCTION) I WANT THE USER TO BE
ABLE TO CLICK ON ONE OF THE CHECKBOXES AND SEE MORE
INPUT BOXES APPEAR. HAS ANYONE DONE SOMETHING LIKE THIS?
IF SO, WHAT IS THE BEST APPROACH FOR ME TO GET THIS DONE?
________
enter # of input0A |_______| [submit] [reset]
------------------------------*-------------------------
READ: THE FORM 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]
------------------------------*-------------------------
READ: THE FORM BELOW IS THE RESULTS OF CLICKING THE FIRST
CHECKBOX ABOVE
________ ________ ________
input1A |_______| [] input2A |_______| input3A |_______|
________
input1B |_______| [] check here to add input2B and input3B
[submit] [reset]

If you don't have many inbox to display try using div's labels and
changing their style.display property. It doesn't create the fields but
it hide/display them, so the feeling is the same. That's the only
solution i know with client side code. With server side code it would
be easier.

Example:

<html>
<head>
<title>Generati ng Fields</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>

<body>
<script language="JavaS cript" type="text/JavaScript">

var maxFields=4;

function showInputs() {

n=document.getE lementById("num ber_of_fields") .value;
for (i=1;i<=n&&i<ma xFields;i++) {
field=eval("doc ument.getElemen tById('field"+i +"')");
field.style.dis play="block";
}
}
</script>
<form name="form1" method="post" action="">
<p>number of fields:
<input type="text" name="number_of _fields" id="number_of_f ields">
</p>

<p>
<input type="button" name="Submit" value="show fields"
onClick="showIn puts()">
</p> </form>
<form name="form1">
<div id="field1" style="display: none">
<p>field1:
<input type="text" name="textfield ">
</p>
</div>
<div id="field2" style="display: none"><p> field2:
<input type="text" name="textfield 2">
</p>
</div>
<div id="field3" style="display: none"><p>field3 :
<input type="text" name="textfield 3">
</p>
</div>
</form>
<p>&nbsp;</p>
<p>&nbsp; </p>
</body>
</html>

Jul 23 '05 #3
/*
guilllet,

Dude thanks for the code but I already know how to do that... Look at
the second form I drew. It has check boxes there that will allow the
user to add additional fields. These check boxes should view an
additional two fields. Check out my showInputs().
*/

function showInputs() {
var howMany = document.form1. number_of_field s.value;
inter = "'";
data = "";

if (howMany < 16 && howMany > -1) {
for (i=1; i <= howMany; i++) {
data = data + " <input type='text' size=10 name=" + inter +
"inputMe[]" + i + inter + "'>" + " <input type='checkbox'
onClick='showIn puts2();' id='tag_1' name='checkMe'" + i + "'><br>";
}

field1.innerHTM L = data;

}else {
window.alert("P lease select up to 15 entries.");
}
}

#This all goes into a div tag. check it out...
<form>
<div id="field1" style="possitiv e:absolute"></div>
</form>
#Your help will not go unnoticed. Thanks!

Jul 23 '05 #4
This is racking my brain!!!!

Jul 23 '05 #5
ok, i see.
so your problem is the last part, that's it?
tomorrow i'll try to find out how to make it work.
what kind of error do you get?

Jul 23 '05 #6
pizzy wrote:
/*
guilllet,

Dude thanks for the code but I already know how to do that... Look at
the second form I drew. It has check boxes there that will allow the
user to add additional fields. These check boxes should view an
additional two fields. Check out my showInputs().
*/
Please quote what you are replying to and trim any excess to
reduce message length.

Please wrap code manually at about 65 characters to ensure a
couple of posts and replys without wrapping. This makes it much
easier for others to fix your code.

Indent code using 2 or 4 spaces (2 preferred) to stop wrapping
and keep lines to a reasonable length.

All the above is on the group FAQ:

<URL:http://www.jibbering.c om/faq/>

function showInputs() { [...] for (i=1; i <= howMany; i++) {
data = data + " <input type='text' size=10 name=" + inter +
"inputMe[]" + i + inter + "'>" + " <input type='checkbox'
onClick='showIn puts2();' id='tag_1' name='checkMe'" + i + "'><br>";
}

This will create inputs with identical ids and likely some with
identical names, thereby creating invalid HTML.
field1.innerHTM L = data;

}else {
window.alert("P lease select up to 15 entries.");


Below is a better way of doing what you are attempting. It uses
DOM methods to add the extra elements and a selector to ensure
correct input. The checkboxes are added to the form, but you
could put them into a separate div if you want.

I've used document.write to create the options for brevity.

I've also added a dummy showInputs2() function.
<script type="text/javascript">
function showInputs(f,v) {
var i = 0,
oInp, oLabel;
while (i++ < v){
oLabel = document.create Element('label' );
oInp = document.create Element('input' );
oInp.type = 'checkbox';
oInp.onclick = function() {showInputs2(th is)};
oInp.id = 'tag_' + i;
oInp.name = 'checkMe' + i;
oLabel.appendCh ild(oInp);
oLabel.appendCh ild(document.cr eateTextNode(i) );
oLabel.appendCh ild(document.cr eateElement('br '));
f.appendChild(o Label);
}
}
function showInputs2(x) {
alert(
'function showInputs2()'
+ '\ncalled from ' + x.nodeName
+ ' ' + x.type
+ '\nid: ' + x.id
+ ' name: ' + x.name
);
}

</script>

# This all gets added to the form. Check it out...
<form>
<select onchange="
showInputs(this .form,
this[this.selectedIn dex].value);
">
<option selected>Select how many checkboxes to add</option>
<br>
<script type="text/javascript">
for (var i=1; i<17; i++) {
document.write( '<option value="' + i
+ '">' + i + '<\/option>');
}
</script>
</select><br>
<input type="reset" onclick="
var labels = this.form.getEl ementsByTagName ('label');
var i = labels.length;
while (i--){
labels[i].parentNode.rem oveChild(labels[i]);
}
"><br>
</form>


--
Rob
Jul 23 '05 #7
I see that you have the oInp.onclick sending to showInputs2. How am I
able to create a unique input box in the showInputs2 function?

<script type="text/javascript">
function showInputs(f,v) {
var i = 0,
oInp, oLabel;
while (i++ < v){

oLabel = document.create Element('label' );
oLabel2 = document.create Element('label' );
oInp = document.create Element('input' );
oDiv = document.create Element('div');

oInp.type = 'checkbox';
oInp.onclick = function() { showInputs2(thi s)};
oInp.id = 'tag_' + i;
oInp.name = 'checkMe' + i;

oDiv.type = 'div';
oDiv.id = 'showTag' + i;
oDiv.style.posi tion = 'relative';

oLabel.appendCh ild(document.cr eateTextNode(i) );
oLabel.appendCh ild(oInp);
oLabel.appendCh ild(document.cr eateElement('br '));

oLabel2.appendC hild(document.c reateTextNode(" The text box should
display here after I click the check box"));
oLabel2.appendC hild(oDiv);

field1.appendCh ild(oLabel);
field1.appendCh ild(oLabel2);
}
}

function showInputs2(x) {
alert( 'function showInputs2()' + '\ncalled from ' + x.nodeName + ' '
+ x.type + '\nid: ' + x.id + ' name: ' + x.name );

}
</script>

<form>
<select
onchange="showI nputs(this.form ,this[this.selectedIn dex].value);">
<option selected>Select how many checkboxes to add</option>
<br>
<script type="text/javascript">
for (var i=1; i<17; i++) {
document.write( '<option value="' + i
+ '">' + i + '<\/option>');
}
</script>
</select><br>
<input type="reset" onclick="
var labels = this.form.getEl ementsByTagName ('label');
var i = labels.length;
while (i){
labels[i].parentNode.rem oveChild(labels[i]);
}
"><br>
</form>
<form name="myForm">< div id="field1" style="position :relative;">
</div></form>

Jul 23 '05 #8

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...
1
1889
by: zoneal | last post by:
Hello there, Currently I am working with the project which needs dynamically generated checkboxes and i have generated dynamic checkboxes but i am facing problem with getting the value of selected checkboxes. Problem is described below to understand easily, so please let me know if you come to know the
3
1644
by: Son KwonNam | last post by:
Hello, When there a two forms like the follosings, <form name="source"> <input name="a..." value=".." ..> <input name="a..." value=".." ..> <input name="a..." value=".." ..> <input name="a..." value=".." ..> </form>
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:
2
7053
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
1
2052
by: srneu71 | last post by:
I have a project that requires a dynamically generated matrix table. The table is setup with 4 quadrants (N,S,E,W) with checkboxes to "link" the data in adjacent quadrants. The table has to be able to grow & shrink according to the number of items in each quadrant. I have coded the table as a user control in vb.net. My question is on how to retrieve the data out of the table on a post back. I have tried adding check boxes as straight...
2
3283
by: nduerr | last post by:
I am looking for the VB code to switch the way a form opens on click event. Specifically I have a form created with a default split view setting. I would like to open this form in single form style (minus the datasheet side) from a button on another form. Thanks, Nick
45
27747
by: dizzydangler | last post by:
Hi, I'm new to access (2007, running on XP), but I've gotten some great help from this site on my project so far. However, the more I know, the more complex the problems seem to become.... I'm working with all of my data in a single table and, right now, I've got a form linked to a query that allows the user to input whatever search criteria they want through a variety of controls. I've also created a series of check boxes on the form...
10
1984
by: timleonard | last post by:
How can the following code to be modified to include a duration Column or "Named Range"? I would like to modify it so that a task that has a duration for example, three to five days would show the same task in the calendar on the corresponding days of the week . I believe the area to be modified is between line 250 and 282... Could someone point out the required changes to be made Thanks for any help you could offer
0
9647
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
9959
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...
0
8988
agi2029
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...
1
7509
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
6744
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
5396
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
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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
3
2893
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.