| | |
how to change id by adding new row..
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
If all is working fine then you can use rowIndex as generating id.
javascript Syntax (Toggle Plain Text)
function add(oRow) { var selObj = oRow.getElementsByTagName('select')[0]; if(selObj[0].selected){ // Check for empty ledger entry alert("Please select ledger"); return false; } oRow.parentNode.replaceChild(oRow.cloneNode(true),oRow.parentNode.insertRow(oRow.rowIndex+1)); var inpR = oRow.getElementsByTagName('input'); var inpN = oRow.nextSibling.getElementsByTagName('input'); // Setting id inpN.id = 'textBox_' + oRow.rowIndex+1; var selR = oRow.getElementsByTagName('select')[0]; selR.disabled=true; var selN = oRow.nextSibling.getElementsByTagName('select')[0]; selN.selectedIndex=0; for(i=0;i<inpR.length;i++) { if(inpR[i].disabled){inpR[i].disabled=false;/**/}; if(inpR[i].type=='text'){inpR[i].disabled=true;inpN[i].value='';inpN[i].disabled=false}; if(inpR[i].value=='Add'){inpR[i].value='Edit';inpN[i].disabled=true}; } sumus();knockOut(selN); }
When you think you have done a lot, then be ready for YOUR downfall.
•
•
Join Date: Jun 2009
Posts: 96
Reputation:
Solved Threads: 2
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
inpN.id = 'textBox_' + oRow.rowIndex+1;
.
this code doesnt showing or creating any ID.. :O
Last edited by sam023; Aug 11th, 2009 at 2:21 pm.
•
•
•
•
.JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
inpN.id = 'textBox_' + oRow.rowIndex+1;
.
this code doesnt showing or creating any ID.. :O
javascript Syntax (Toggle Plain Text)
inpR.id = 'textBox_' + oRow.rowIndex+1
When you think you have done a lot, then be ready for YOUR downfall.
•
•
•
•
That's fine the first time a row is cloned but on a second cloning of the same row, would it not generate an identical id to the first?
That's why I advocate maintaining a counter.
Airshow
javascript Syntax (Toggle Plain Text)
inpR.id = 'textBox_' + inpN.length + 1;
If this does not work, you have to use some sort of counter as suggested by Airshow.
When you think you have done a lot, then be ready for YOUR downfall.
Sam023,
Nish is right, CloneNode doesn't have an option for changing ID(s).
Have you tried the idea in my post #3 of this topic? It outlines a way (certainly not the only way) maintain a counter by which cloned elements can be force-renumbered for uniqueness.
Airshow
Nish is right, CloneNode doesn't have an option for changing ID(s).
Have you tried the idea in my post #3 of this topic? It outlines a way (certainly not the only way) maintain a counter by which cloned elements can be force-renumbered for uniqueness.
Airshow
50% of the solution lies in accurately describing the problem!
![]() |
Similar Threads
- Adding a new row in a Datagrid ??????????? (C#)
- How to change color of a row (Java)
- Adding new row in DataGrid (C#)
- Trouble adding new row to DataTable (C#) (C#)
- Having problems with adding a row to a DataSet (VB.NET)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How can we delete array in javascript?
- Next Thread: I want put a clock on my page
| Thread Tools | Search this Thread |
ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate automatically beta box browser bug calendar captchaformproblem checkbox child class close column createrange() css cursor date debugger dependent disablefirebug dom download dropdown editor element embed engine error events explorer ext file form forms getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 ie8 iframe images internet java javascript javascripthelp2020 jawascriptruntimeerror jquery jsf jsfile jump libcurl math media microsoft mimic object onmouseoutdivproblem onreadystatechange parent paypal pdf php player position post problem programming progressbar regex runtime scroll search security select shopping size software sql text textarea unicode w3c web website window windowofwords windowsxp wysiwyg \n






