sir,
am implementing javascript in my project am begineer to javascript and asp.net
can you please help me for the following queries
here am using one dropdownlist which contains number of persons
whenever i select the number from person dropdownlist it will call the javascript function "AdjustRowsToKidsTable"
that should display the data table which contains number of rows according to the dropdownlist value.
these rows contains firstname(textbox),lastname(textbox),Age(dropdownl ist),and diver(checkbox)
dropdownlist contains 12 numbers
if i choose 10 and above from dropdownlist it will display checkbox corresponding to that row
it works properly but i have problem that not display checkbox pls help me........
now i need your help to implement the above in javascript
Hereby i enclosed the code
Please guide me sir,
Thanking You,
S.Senthil Nathan
function AdjustRowsToKidsTable(form, ddl)
{
var tbl = document.getElementById('tblChildren');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var i = 0
var iteration = lastRow;
var diff = (ddl.options[ddl.selectedIndex].value - (iteration-1));
// alert(ddl.options[ddl.selectedIndex].value, diff);
if ( diff > 0) { // add rows
for (i=iteration;i<=ddl.options[ddl.selectedIndex].value;i++) {
var row = tbl.insertRow(lastRow);
row.bgColor='white';
// First Name
var cellLeft = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txt_fname_child' + iteration;
el.id = 'txt_fname_child' + iteration;
el.maxlength = 45;
el.size = 20;
// el.class = "standard-text";
cellLeft.appendChild(el);
// Last Name
var cellMiddle = row.insertCell(1);
var eln = document.createElement('input');
eln.type = 'text';
eln.name = 'txt_lname_child' + iteration;
eln.id = 'txt_lname_child' + iteration;
el.maxlength = 45;
eln.size = 20;
// eln.class = "standard-text";
cellMiddle.appendChild(eln);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'ddl_Age' + iteration;
sel.options[0] = new Option('1', '1');
sel.options[1] = new Option('2', '2');
sel.options[2] = new Option('3', '3');
sel.options[3] = new Option('4', '4');
sel.options[4] = new Option('5', '5');
sel.options[5] = new Option('6', '6');
sel.options[6] = new Option('7', '7');
sel.options[7] = new Option('8', '8');
sel.options[8] = new Option('9', '9');
sel.options[9] = new Option('10', '10');
sel.options[10] = new Option('11', '11');
sel.options[11] = new Option('12', '12');
cellRightSel.appendChild(sel);
}
// form.txtNoChildren.value = i-1; // set value with numbers
}
if ( diff < 0 ) { // delete rows
for (i=diff;i<0;i++) {
var lastRow = tbl.rows.length;
// alert(lastRow);
if (lastRow > 2) {
tbl.deleteRow(lastRow - 1);
// form.txtNoChildren.value = lastRow-2;
} else {
// form.txtNoChildren.value = lastRow-1;
}
}
}
}
1 8723
sir,
am implementing javascript in my project am begineer to javascript and asp.net
can you please help me for the following queries
here am using one dropdownlist which contains number of persons
whenever i select the number from person dropdownlist it will call the javascript function "AdjustRowsToKidsTable"
that should display the data table which contains number of rows according to the dropdownlist value.
these rows contains firstname(textbox),lastname(textbox),Age(dropdownl ist),and diver(checkbox)
dropdownlist contains 12 numbers
if i choose 10 and above from dropdownlist it will display checkbox corresponding to that row
it works properly but i have problem that not display checkbox pls help me........
now i need your help to implement the above in javascript
Hereby i enclosed the code
Please guide me sir,
Thanking You,
S.Senthil Nathan
function AdjustRowsToKidsTable(form, ddl)
{
var tbl = document.getElementById('tblChildren');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var i = 0
var iteration = lastRow;
var diff = (ddl.options[ddl.selectedIndex].value - (iteration-1));
// alert(ddl.options[ddl.selectedIndex].value, diff);
if ( diff > 0) { // add rows
for (i=iteration;i<=ddl.options[ddl.selectedIndex].value;i++) {
var row = tbl.insertRow(lastRow);
row.bgColor='white';
// First Name
var cellLeft = row.insertCell(0);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txt_fname_child' + iteration;
el.id = 'txt_fname_child' + iteration;
el.maxlength = 45;
el.size = 20;
// el.class = "standard-text";
cellLeft.appendChild(el);
// Last Name
var cellMiddle = row.insertCell(1);
var eln = document.createElement('input');
eln.type = 'text';
eln.name = 'txt_lname_child' + iteration;
eln.id = 'txt_lname_child' + iteration;
el.maxlength = 45;
eln.size = 20;
// eln.class = "standard-text";
cellMiddle.appendChild(eln);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'ddl_Age' + iteration;
sel.options[0] = new Option('1', '1');
sel.options[1] = new Option('2', '2');
sel.options[2] = new Option('3', '3');
sel.options[3] = new Option('4', '4');
sel.options[4] = new Option('5', '5');
sel.options[5] = new Option('6', '6');
sel.options[6] = new Option('7', '7');
sel.options[7] = new Option('8', '8');
sel.options[8] = new Option('9', '9');
sel.options[9] = new Option('10', '10');
sel.options[10] = new Option('11', '11');
sel.options[11] = new Option('12', '12');
cellRightSel.appendChild(sel);
}
// form.txtNoChildren.value = i-1; // set value with numbers
}
if ( diff < 0 ) { // delete rows
for (i=diff;i<0;i++) {
var lastRow = tbl.rows.length;
// alert(lastRow);
if (lastRow > 2) {
tbl.deleteRow(lastRow - 1);
// form.txtNoChildren.value = lastRow-2;
} else {
// form.txtNoChildren.value = lastRow-1;
}
}
}
}
Where is the code for displaying the checkbox?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: George Durzi |
last post by:
I have a JavaScript called common.js that is referenced by every ASPX in my
web application. In common.js, I have a funtion called findText (which I use
to help me navigate through drop down lists...
|
by: Phl |
last post by:
hi,
does any know why my javascript dropdownlist in my user control will
only appear if I have my code as follows:
// create an instance of the user control
Control UCAdminDDMenu =...
|
by: Caesar Augustus |
last post by:
I'm having a problem with two different javascript controls in my app.
The first chuck of javascript that I pasted into my app is the
client-side calendar control popup which works fine when first...
|
by: Oscar |
last post by:
I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :
var dd = document.getElementById("DropDownList1");
dd.Items.Add("1990");...
|
by: =?Utf-8?B?Qw==?= |
last post by:
I have a dropdown list as below.
I add an onchnage attribute in my codebehind to call some Javascript.
I want to get the selected text from my dropdown. What am I doing wrong below?
...
|
by: Radu |
last post by:
Hi. I have the following problem - I need to build a user-control in
asp.net (an ascx) to somehow allow the users to search by first name
or last name among a big (~10.000 records) email addresses...
|
by: John Kotuby |
last post by:
Hi all...
I am trying to do a simple thing and maybe am missing something elementary.
I have created a Javascript function at the top of a page which is meant to
enable editing of an HTML input...
|
by: =?Utf-8?B?cm9kY2hhcg==?= |
last post by:
hey all,
imagine this for a moment if you will:
i have a row in a gridview that when it is in edit mode there is a column
that contains a dropdownlist and 2nd column that contains a user control....
|
by: pankajsingh5k |
last post by:
Dear All,
Please help me...
I had read an article to lazy load a tab in a tabcontainer using an update panel on
http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
| |