Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-25-2012, 11:54 AM   PM User | #1
ramuP
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ramuP is an unknown quantity at this point
Please help in getting different rowid's for newly added row

Hi everyone,

I have a necessity to add records to a table (Grid) using javascript.

I have a problem while deleting rows and adding new rows(Getting same rowid for last two rows) ...

When creating new row i had taken existing rowCount, but when deleting in between row i am getting same rowid for the last two...


Please help to overcome this issue...


Here i am attached my sample code...

Thanks in advance....

var tab = document.getElementById("tabaddrow");
var rc = tab.rows.length;
var row = tab.insertRow(rc);
var send = parseInt(rc) + 1;


var cell0 = row.insertCell(0);
var element0 = document.createElement("select");
element0.id = "sel@" + send + "_1";
element0.options[0] = new Option("--Select--", "0");
element0.options[1] = new Option("Text Box", "1");
element0.options[2] = new Option("Check Box", "2");
element0.options[3] = new Option("Radio Button", "3");
element0.options[4] = new Option("Password", "4");
element0.options[5] = new Option("Select Box", "5");
cell0.appendChild(element0);
var onchangeFunction = new Function("", "var elem = document.getElementById('sel@" + send + "_1'); selectval('sel@" + send + "_1');");
element0.onchange = onchangeFunction


//*********code for deleting***********


var table = document.getElementById("tabaddrow");
var rowNumber = rowId.parentNode.parentNode.rowIndex;


var agree = confirm("Are you sure you wish to delete the row?");
if (agree) {

if (parseInt(document.getElementById("tabaddrow").rows.length) > 0) {

//alert(document.getElementById("tabaddrow").rows.length);
document.getElementById("tabaddrow").deleteRow(rowNumber);


}


}


Thanks in advance,
ramuP is offline   Reply With Quote
Old 03-26-2012, 07:42 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Please see the other (double) posting for an answer.
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:08 PM.


Advertisement
Log in to turn off these ads.