Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Thanked 0 Times in 0 Posts

    Lightbulb Please help me 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");
    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) {




    Thanks in advance,

  2. #2
    Senior Coder
    Join Date
    Dec 2010
    Thanked 570 Times in 563 Posts
    Why don't you just store the highest id number in a (global) variable and increase this variable while creating a new row? This way you won't have double entries.

  3. #3
    Regular Coder
    Join Date
    Jun 2008
    Thanked 15 Times in 15 Posts
    Why dont you use the DB Store functions itself? (Sorry for my bad english)
    What do you try to make. Smartphoneapps?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts