Home > front end >  How to get under a table cell within the select value
How to get under a table cell within the select value

Time:11-14



 for (var I=1; I & lt; Rows. Length; I++) {
For (var j=0; J & lt; Rows [I] cells. Length; J++) {//traverse the td
//var obj=rows [I] cells [j]. J getElementsByTagName (" select ") [0];
Alert (" first "+ (I + 1) +", the first "+ (j + 1) +" td values: "+ rows [I] cells [j]. Journal of innerHTML +", ");//the contents of the output every td
}


Traverse the bank, the select options within the cell how to obtain the content of the

According to the online using the
Rows [I] cells [j] getElementsByTagName (" select ") [0]. Value
Tip without the value of this attribute

CodePudding user response:

Not every td inside with the select (and not find conditions), so must find errors (in not save the select tag column obj is undefined)

[tableData=https://bbs.csdn.net/topics/
{
Id: '0001',
Name: 'the first line of data,
Status: 0//0 to audit 1 exception 2 through
}
]

Can actually change the way of thinking, dynamically generated form the data to add an attribute (if the API return data should have this field), the status=0-2
When the select change value dynamic update to the status of tableData attribute

When submitted for the currently selected row/click the data will be able to get the status

CodePudding user response:

This cell, I will get, is to take out the inside of the value, I have a sore point skull

CodePudding user response:

Try this method
Var select=document. GetElementById (id);
for(var i=0; i