2011-12-19 12 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> 

上記のフォームでは、前のフィールドで選択した値に基づいてフィールドを有効にしたいとします。たとえば、最初のドロップダウンにはいを選択すると、2番目のドロップダウンが有効になります。 2番目のドロップダウンにはいを選択した場合は、3番目のドロップダウンが有効になるなどのようになります。これをどのように実装できますか? 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

関連する問題