2012-03-12 5 views
0

동적으로 생성 된 학생 목록이 있습니다. 나는 사용자가 출석을 포착하고 결석 할 경우 출석을 포기할 것인지 말 것인지를 묻는다. 존재하는 경우 후자를 기록 할 이유가 없으며 해당 옵션을 사용하지 못하게하고 싶습니다.동적 요소 목록에서 양식 요소 사용

제 문제는 목록에 동적으로 생성되어 출석 (django 템플릿 및 Google 앱 엔진을 통해)을위한 양식 요소가 포함되어 있다는 것입니다.

나는 excused/unexcused 라디오 버튼을 활성화/비활성화하는 데 javascript를 사용하지만이를 수행하는 좋은 방법은 없습니다. 그것은 올바른 변수 사용의 간단한 문제로 보이지만 나는 그것을 알아낼 수 없습니다 (그리고 js는 내가 잘 아는 언어가 아닙니다). 하여 JS 함수에서 다음을 시도하려고

임 :이 동적 형태의 콘텐츠의 일상적인 문제가 될 것이다 그러나 나는 해결책을 찾는 데 실패하고있다처럼

//bring the name and ID of the clicked element in to the function 
function disable_enable(rdoIdIN, rdoNameIN){ 
//create a simple string of the common portion of the submitting button Im looking for, the word, "absent" 
var rdoId = rdoIdIN.substring(0,6); 
//use the dynamic portion of the clicked element name to generate the dynamic name of the element I want to enable 
var rdoStatusName = 'attendcategory' + rdoNameIN.substring(10) 

if (document.formname.rdoID == 'absent'){ 
    //enable the excused/unexcused elements 
    document.formname.rdoStatusName[0].disabled=false; 
    document.formname.rdoStatusName[1].disabled=false; 
} 

보인다.

답변

0

당신은 elements-collection 사용할 수 있습니다 :

document.formname.elements[rdoStatusName][0].disabled=false; 
+0

감사를 완벽하게 일했다. – techkilljoy