사실 나는 자바 스크립트 (실제로 jquery)를 사용하여 테이블의 각 행에 대한 양식에 문제가 있습니다.
Lothre1이 말했듯이, "렌더링 프로세스의 일부 브라우저는 선언 직후에 요소 외부에 입력을 남기고 양식 태그를 닫을 것입니다."
내 입력 필드를 양식 외부로 만들므로 JAVASCRIPT를 사용하여 DOM을 통해 양식의 하위 항목에 액세스 할 수 없습니다.
일반적으로 다음 JQUERY 코드는 작동하지 않습니다.
$('#id_form :input').each(function(){/*action*/});
// this is supposed to select all inputS
// within the form that has an id ='id_form'
그러나 위의 예제는 렌더링 된 HTML에서 작동하지 않습니다.
<table>
<form id="id_form"></form>
<tr id="tr_id">
<td><input type="text"/></td>
<td><input type="submit"/></td>
</tr>
</table>
나는 여전히 깨끗한 솔루션을 찾고 있습니다 (DOM을 걷기 위해 TR 'id'매개 변수를 사용하면이 특정 문제를 해결할 수 있지만)
더러운 솔루션은 (jquery의 경우) 다음과 같습니다.
$('#tr_id :input').each(function(){/*action*/});
// this will select all the inputS
// fields within the TR with the id='tr_id'
위의 예는 작동하지만 FORM 대신 TR을 참조하고 AJAX가 필요하기 때문에 실제로 "깨끗한"것은 아닙니다.
편집 : jquery / ajax를 사용한 전체 프로세스는 다음과 같습니다.
//init data string
// the dummy init value (1=1)is just here
// to avoid dealing with trailing &
// and should not be implemented
// (though it works)
var data_str = '1=1';
// for each input in the TR
$('#tr_id :input').each(function(){
//retrieve field name and value from the DOM
var field = $(this).attr('name');
var value = $(this).val();
//iterate the string to pass the datas
// so in the end it will render s/g like
// "1=1&field1_name=value1&field2_name=value2"...
data_str += '&' + field + '=' + value;
});
//Sendind fields datawith ajax
// to be treated
$.ajax({
type:"POST",
url: "target_for_the_form_treatment",
data:data_string,
success:function(msg){
/*actions on success of the request*/
});
});
이런 식으로 "target_for_the_form_treatment"는 마치 양식이 그에게 전송 된 것처럼 POST 데이터를 수신해야합니다 (post [1] = 1의 appart이지만이 솔루션을 구현하려면 대신 data_str의 후행 '&'를 처리하는 것이 좋습니다) .
여전히이 솔루션이 마음에 들지 않지만 dataTables jquery 플러그인으로 인해 TABLE 구조를 사용해야합니다.