Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. how to store values from dynamically added rows into database

how to store values from dynamically added rows into database

Scheduled Pinned Locked Moved Web Development
databasedata-structureshelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manojramakrishnan
    wrote on last edited by
    #1

    hi to all, i have faced a problem in storing the values in the textfield created dynamically by clicking a button. the insert query in the code stores only the first value in the array that is the value from default textfield in the form not the dynamically created ones. I am using the code: var glob; glob = 1; function insert_row(tablename) { var the_table = document.getElementById(tablename); var new_row_index = the_table.rows.length; glob = glob + 1; the_table.insertRow(new_row_index); the_table.rows[new_row_index].insertCell(0); the_table.rows[new_row_index].cells[0].innerHTML =(the_table.rows[0].innerHTML); } function removeRowFromTable(tblSample) { var tbl = document.getElementById(tblSample); var lastRow = tbl.rows.length; if (lastRow > 1) tbl.deleteRow(lastRow - 1); } function removeRowFromTable(tblSample) { var tbl = document.getElementById(tblSample); var lastRow = tbl.rows.length; if (lastRow > 1) tbl.deleteRow(lastRow - 1); } function validateRow(frm) { var chkb = document.getElementById('chkValidate'); if (chkb.checked) { var tbl = document.getElementById('tblSample'); var lastRow = tbl.rows.length - 1; var i; for (i=1; i<=lastRow; i++) { var aRow = document.getElementById('txtRow' + i); if (aRow.value.length <= 0) { alert('Row ' + i + ' is empty'); return false; } } } openInNewWindow(frm); }

    Text Field: *

    Comments:

    G 1 Reply Last reply
    0
    • M manojramakrishnan

      hi to all, i have faced a problem in storing the values in the textfield created dynamically by clicking a button. the insert query in the code stores only the first value in the array that is the value from default textfield in the form not the dynamically created ones. I am using the code: var glob; glob = 1; function insert_row(tablename) { var the_table = document.getElementById(tablename); var new_row_index = the_table.rows.length; glob = glob + 1; the_table.insertRow(new_row_index); the_table.rows[new_row_index].insertCell(0); the_table.rows[new_row_index].cells[0].innerHTML =(the_table.rows[0].innerHTML); } function removeRowFromTable(tblSample) { var tbl = document.getElementById(tblSample); var lastRow = tbl.rows.length; if (lastRow > 1) tbl.deleteRow(lastRow - 1); } function removeRowFromTable(tblSample) { var tbl = document.getElementById(tblSample); var lastRow = tbl.rows.length; if (lastRow > 1) tbl.deleteRow(lastRow - 1); } function validateRow(frm) { var chkb = document.getElementById('chkValidate'); if (chkb.checked) { var tbl = document.getElementById('tblSample'); var lastRow = tbl.rows.length - 1; var i; for (i=1; i<=lastRow; i++) { var aRow = document.getElementById('txtRow' + i); if (aRow.value.length <= 0) { alert('Row ' + i + ' is empty'); return false; } } } openInNewWindow(frm); }

      Text Field: *

      Comments:

      G Offline
      G Offline
      Girish Nambiar
      wrote on last edited by
      #2

      the html - should be - and the javascript should also generate the controls with name="increment[]". If this fails then try to put the index for the control through javascript i.e. increment[0] for the first one, increment[1] for the second one .... This will result in an array of values which you can handle through the PHP script after form post.

      Girish Nbr.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups