dcsimg
How to create a dynamic textbox using javascript.Please help me
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   datta_saru
Posted On:   Thursday, May 11, 2006 09:10 AM

Hi All!
I have a requirement like this:
name :txtbox1 mark:textbox2 total:txtbox3 add remove buttons
when i click add button new row has to come
when i click delete button the current row has to be deleted. Also, I want to capture the data submitted in textboxes.

How can i do that using HTML/Javascript.
Thanks in advance!

Re: How to create a dynamic textbox using javascript.Please help me

Posted By:   Anonymous  
Posted On:   Saturday, May 13, 2006 06:16 AM

If u are using a table then u can use the following code.

When clicked on add the following function can be used

function add() {
var tableObj = document.getElementById('yourtableId');
var rowObj = document,createElement('tr');
tableCell = document.createElement('td');
firstCell.innerHTML = 'name: ';
rowObj.apppendChild(tableCell);
tableCell = document.createElement('td');
tableCell.innerHTML = 'mark: ';
rowObj.apppendChild(tableCell);
tableCell = document.createElement('td');
tableCell.innerHTML = 'total: ';
rowObj.apppendChild(tableCell);
tableCell = document.createElement('td');
tableCell.innerHTML = '';
tableCell = document.createElement('td');
tableCell.innerHTML = '';
rowObj.apppendChild(tableCell);
tableObj.appendChild(rowObj);
}

function remove(obj) {
var rowObj = obj.parentNode.parentNode;
var tableObj = docuemnt.getElementById('yourtableId');
tableObj.removeChild(rowObj);
}

you can read the value in the textboxes by giving them unique ids and using document.getElementById('uniqueid').value

Hope this solves your problem
About | Sitemap | Contact