943,778 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 11th, 2009
0

Re: how to change id by adding new row..

If all is working fine then you can use rowIndex as generating id.

javascript Syntax (Toggle Plain Text)
  1. function add(oRow)
  2. {
  3. var selObj = oRow.getElementsByTagName('select')[0];
  4. if(selObj[0].selected){ // Check for empty ledger entry
  5. alert("Please select ledger");
  6. return false;
  7. }
  8. oRow.parentNode.replaceChild(oRow.cloneNode(true),oRow.parentNode.insertRow(oRow.rowIndex+1));
  9. var inpR = oRow.getElementsByTagName('input');
  10. var inpN = oRow.nextSibling.getElementsByTagName('input');
  11. // Setting id
  12. inpN.id = 'textBox_' + oRow.rowIndex+1;
  13. var selR = oRow.getElementsByTagName('select')[0];
  14. selR.disabled=true;
  15. var selN = oRow.nextSibling.getElementsByTagName('select')[0];
  16. selN.selectedIndex=0;
  17. for(i=0;i<inpR.length;i++)
  18. {
  19. if(inpR[i].disabled){inpR[i].disabled=false;/**/};
  20. if(inpR[i].type=='text'){inpR[i].disabled=true;inpN[i].value='';inpN[i].disabled=false};
  21. if(inpR[i].value=='Add'){inpR[i].value='Edit';inpN[i].disabled=true};
  22. } sumus();knockOut(selN);
  23. }
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Aug 11th, 2009
0

Re: how to change id by adding new row..

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. 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.
Reputation Points: 11
Solved Threads: 6
Junior Poster
sam023 is offline Offline
164 posts
since Jun 2009
Aug 11th, 2009
0

Re: how to change id by adding new row..

Click to Expand / Collapse  Quote originally posted by Luckychap ...
If all is working fine then you can use rowIndex as generating id.
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
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,526 posts
since Apr 2009
Aug 11th, 2009
0

Re: how to change id by adding new row..

Click to Expand / Collapse  Quote originally posted by sam023 ...
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. inpN.id = 'textBox_' + oRow.rowIndex+1;
.
.
this code doesnt showing or creating any ID.. :O
Sorry for typo it must be:

javascript Syntax (Toggle Plain Text)
  1. inpR.id = 'textBox_' + oRow.rowIndex+1
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Aug 11th, 2009
0

Re: how to change id by adding new row..

Click to Expand / Collapse  Quote originally posted by Airshow ...
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
Well if rowIndex is same always, then inpN.length can be used to set ids:

javascript Syntax (Toggle Plain Text)
  1. inpR.id = 'textBox_' + inpN.length + 1;

If this does not work, you have to use some sort of counter as suggested by Airshow.
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Aug 17th, 2009
0

Re: how to change id by adding new row..

none of the code is working..
.
.
can anybody tell how to use counter..? :O
Reputation Points: 11
Solved Threads: 6
Junior Poster
sam023 is offline Offline
164 posts
since Jun 2009
Aug 17th, 2009
0

Re: how to change id by adding new row..

... + i++
Reputation Points: 120
Solved Threads: 61
Posting Pro
Troy III is offline Offline
511 posts
since Jun 2008
Aug 17th, 2009
0

Re: how to change id by adding new row..

didnt get u.. :O
be more specific..
thank you
Reputation Points: 11
Solved Threads: 6
Junior Poster
sam023 is offline Offline
164 posts
since Jun 2009
Aug 17th, 2009
0

Re: how to change id by adding new row..

I dont think it is possible to change Id.. by using CloneNode...!!
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
nish123 is offline Offline
83 posts
since Apr 2009
Aug 17th, 2009
0

Re: how to change id by adding new row..

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
Sponsor
Reputation Points: 318
Solved Threads: 358
WiFi Lounge Lizard
Airshow is offline Offline
2,526 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Associative Array in Javascript
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: I want put a clock on my page





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC