2011-12-19 6 views
1
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" 
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" 
xmlns:xforms="http://www.w3.org/2002/xforms"> 

<xhtml:head> 
    <xhtml:title>Orbeon XForms Sample Form</xhtml:title> 

    <xforms:model> 
    <xforms:instance id="myModel" xmlns=""> 
    <form> 
      <type> 

       <radio></radio> 
      </type> 
      <type> 

       <radio></radio> 
      </type> 
      <type> 

       <radio></radio> 
      </type> 
    </form> 
    </xforms:instance> 



    <xforms:bind id="radio" nodeset="instance('myModel')/type/radio"/> 


    </xforms:model> 
</xhtml:head> 

<xhtml:body> 

    <table> 
     <tr> 

     </tr> 
     <tr><td> 
      <table> 

      <xforms:repeat nodeset="instance('myModel')/type"> 

       <tr> 
        <td> 
         <xforms:output ref="position()"/> 
        </td> 
        <td/> 
        <td> 
         <xforms:select1 ref="radio" incremental="true" appearance="minimal"> 
          <xforms:item> 
           <xforms:label>Please Select</xforms:label> 
           <xforms:value></xforms:value> 
          </xforms:item><xforms:item> 
           <xforms:label>Yes</xforms:label> 
           <xforms:value>Yes</xforms:value> 
          </xforms:item> 
          <xforms:item> 
           <xforms:label>No</xforms:label> 
           <xforms:value>No</xforms:value> 
          </xforms:item> 
          <xforms:alert>Required</xforms:alert> 
         </xforms:select1> 
        </td> 
       </tr> 
      </xforms:repeat> 
      </table> 
     </td> 
     </tr> 

    </table> 

</xhtml:body> 

</xhtml:html> 

위의 양식에서 이전 필드에서 선택한 값을 기준으로 필드를 활성화하려고합니다. 예를 들어 첫 번째 드롭 다운에 을 선택한 경우 두 번째 드롭 다운 만 사용하도록 설정해야합니다. 두 번째 드롭 다운에 을 선택하면 세 번째 드롭 다운 만 활성화되어야합니다. 어떻게 구현할 수 있습니까? xforms-value-changed 이벤트에서 뭔가를 할 수 있습니까? 아니면 xforms : bind에서 이것을 구현할 수 있습니까?다른 필드의 값 변경시 필드를 사용하거나 사용하지 않도록 설정하는 방법은 무엇입니까?

답변

2

의심스러운 것이므로 xforms:bind을 사용하면됩니다. 다음은 귀하의 예제에서 일을 할 것입니다 :

<xforms:bind id="radio" nodeset="instance('myModel')/type/radio" 
    relevant="empty(../preceding-sibling::type) 
       or ../preceding-sibling::type[1]/radio = 'Yes'"/> 

여기서 가장 미묘한 부분은 현재의 앞에 오는 type 요소를 얻을 수있는 preceding axis의 사용이다.

+0

네, 정확하게 원했던 방식으로 작동합니다 .. 정말 감사드립니다 .. :) – Akshay

+0

우수합니다. 확인해 주셔서 감사합니다. – avernet