javascript - select dynamically muiltiple element from a html table -


I want to dynamically select the value from the list coming from the database with JavaScript. My table & lt; Td> and & lt; Tr & gt; Dynamically created from a database I manage the "id" attribute with 0, for the loop in front of it. Also like the "ID" of the selection button

  & lt; Tr & gt; & Lt; Td id = "pres0" & gt; Bear & lt; / Td> & Lt; Td id = "cod0" & gt; Ddfd & lt; / Td> & Lt; Td id = "id0" & gt; 23 & lt; / Td> & Lt; Td> & Lt; Input type = "button" value = "select" id = "id-but-select0" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td id = "pres1" & gt; Cat & lt; / Td> & Lt; Td id = "cod1" & gt; Ez & lt; / Td> & Lt; Td id = "id1" & gt; 121 & lt; / Td> & Lt; Td> & Lt; Input type = "button" value = "select" id = "id-but-select1" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt ;! - Total number of databases selected - & gt; & Lt; Input id = "nbra" type = "hidden" value = "2" & gt;  

What do I need when I put it on the selection button, I have a warning that shows the value of each TD ID in javascript or jquery

I recommend:

  showCellValues ​​(e) {// any default tasks Preventing: e. Stop shock (); // To create a variable to cross the 'this' caching: var self = this, // DOM for later (potential) (to follow the loop): cell = self, // to work Whether to require text content or internal text // // text in a node: textProp = 'textContent' in the document? 'Text Content': 'Internal Text'; // While the cell element is a & lt; Td> No element: while (cell.tagName.toLowerCase ()! == 'TD') {// We assign current parental nodes to cell variables, and then go again: cell = cell.parentNode; } // An empty array to keep the key-value added: var keyValues ​​= []; // Turn the node list of the child elements of the parent node on an array, // array again on that heat. Protopp For pre (): [] .slice.call (cell.parentNode.children, 0) .for eca (function) {// We want to get value from siblings (cell / clicked & lt; If / (if the cell is not current L), then we should: String a string / / key: value push (key.values.push (el.id + ': '+ El [textProp]);}}; // Show output, use a warning, or return or whatever your // requirements: console.log (keyValues.join (', '));} / / Type = buttons * and * value = all of the selections Convert diallist // is within an & lt; td & gt; element in an array, and walk on that array: [] .slice.call (document.querySelectorAll ('td> Input [type ='] "] [Value =" select "] '), 0) .for unit (function (button) {/' click 'event-operator fun binding Ction (showCellValues): button AddEventListener (' click ', Showsellwell) ;});  

Reference:

  • . *.
  • .
  • .
  • .

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -