2012-07-06 8 views
0

를 기본 설정에서 변경되는 모든 체크 박스의 ID를 가져옵니다 : 내가 확인하는 확인란을 얻거나 할 수 있도록나는 <code>html</code> 다음 한

<table id="share">       
     <tr class="row"> 
       <td class="optionsCell">Share Clip postings : </td> 
       <td class="cell"><input type="checkbox" id="shareClipPost" /><span>Yes</span></td> 
     </tr> 
     <tr class="row"> 
       <td class="optionsCell">Share my favorites : </td> 
       <td class="cell"><input type="checkbox" id="shareFavorites" /><span>Yes</span></td> 
     </tr> 
     <tr class="row"> 
       <td class="optionsCell">Share all ratings given/changed : </td> 
       <td class="cell"><input type="checkbox" id="shareRating" /><span>Yes</span></td> 
     </tr> 
     <tr class="row"> 
       <td class="optionsCell">Share all shows recorded : </td> 
       <td class="cell"><input type="checkbox" id="shareRecorded" /><span>Yes</span></td> 
     </tr> 
     <tr class="row"> 
       <td class="optionsCell">Share all shows viewed : </td> 
       <td class="cell"><input type="checkbox" id="shareView"/><span>Yes</span></td> 
     </tr> 
</table>   

지금 내가 달성하고자하는 것이 적절한 방법입니다 선택하지 않았다. 처음에는 체크 표시가있는 곳에서 ajax 요청에 의해 체크 된 데이터를 체크하고 다른 상자는 체크하지 않은 상태로 유지합니다. 이것은 내 설정에 있습니다. 그래서 지금 나는 사용자가 변경 한 체크 박스 만의 가치를 얻는 방법을 찾아야합니다. 이전에 체크 한 체크 박스를 체크하지 않거나 체크하지 않은 체크 박스를 체크하십시오. 그런 다음 변경된 체크 박스 중 id 만 전달할 수 있습니다. 이제 모든 변경을 단일 변경으로 모두 id's에게 전달합니다.

답변

0

나는 모든 체크 박스에 rel 속성을 추가하는 것과 같이 "원래 상태"를 저장해야한다고 생각합니다. 이 속성에 을 입력하면 체크 박스의 원래 상태를 저장하는 숨김 필드 id 만 작성하면됩니다.

<td class="cell"><input type="checkbox" id="shareRecorded" rel="shareRecordedState" /><span>Yes</span></td> 
<input type="hidden" id="shareRecordedState" value="1"/> 

마지막으로 원래 상태를 확인하면됩니다.

관련 문제