2017-04-07 36 views
0

我有以下代碼。它似乎沒有觸發。基本上我想在選中'個人'時禁用單選按鈕'透支'。如果有更簡單的方法,或者如果你能看到我做錯了什麼。我已經嘗試了下面的兩個選項。xsl當xpath不工作時選擇

<td class="Label" colspan="1" width="50%"> 
    <input class="Label" type="radio" name="selectedFacilityType" value="1" onClick="document.lending.selectedFacilityTypeValue.value=this.value"> 
     <xsl:if test="facilitytype/options[@id='1']='checked'"> 
      <xsl:attribute name="checked"/> 
     </xsl:if> 
     <!-- start --> 
     <xsl:if test="lettertype/type[@id='personal']='checked'"> 
      <xsl:attribute disabled="disabled"/> 
     </xsl:if> 
     <!-- end --> 
    </input>Overdraft 
</td> 

<xsl:choose> 
    <xsl:when test="lettertype/type[@id='personal']='checked'"> 
     <td class="Label" colspan="1" width="50%"> 
      <input class="Label" type="radio" name="selectedFacilityType" value="1" onClick="document.lending.selectedFacilityTypeValue.value=this.value" disabled="disabled"></input>Overdraft 
     </td> 
    </xsl:when> 
    <xsl:otherwise> 
     <td class="Label" colspan="1" width="50%"> 
      <input class="Label" type="radio" name="selectedFacilityType" value="1" onClick="document.lending.selectedFacilityTypeValue.value=this.value"> 
      <xsl:if test="facilitytype/options[@id='1']='checked'"> 
       <xsl:attribute name="checked"/> 
      </xsl:if> 
      </input>Overdraft 
     </td> 
    </xsl:otherwise> 
</xsl:choose> 

示例XML:

<lending> 
<currentbaserate/> 
<lettertype> 
    <type id="personal">checked</type> 
    <type id="business"/> 
    <type id="limited"/> 
</lettertype> 
<saved/> 
<applicantdetails> 
    <name> 
     <title/> 
     <firstname/> 
     <surname/> 
    </name> 
    <address> 
     <addressline1/> 
     <addressline2/> 
     <addressline3/> 
     <addressline4/> 
     <addressline5/> 
    </address> 
    <ourref/> 
    <date/> 
    <salutation/> 
    <facilitysought/> 
    <signame/> 
    <sigposition/> 
    <signameadd/> 
    <sigpositionadd/> 
</applicantdetails> 
<facilitytype> 
    <options id="1">checked</options> 
    <options id="2"/> 
    <options id="3"/> 
    <options id="4"/> 
    <options id="5"/> 
    <options id="6"/> 
    <options id="7"/> 
    <options id="8"/> 
</facilitytype> 

回答

0

我解決了這個用JavaScript來禁用無線電按鈕

0

每個你應該使用XPath '//' 前:

等代替

<xsl:if test="facilitytype/options[@id='1']='checked'"> 

使用

<xsl:if test="//facilitytype/options[@id='1']='checked'"> 

在此腳本的所有實例中添加此項。

它會導致你的期望的輸出

+0

了xsl選擇時的作品,但它只是禁用所有lettertypes例如透支按鈕個人,業務,有限。我希望它只是禁用當個人被選中 – topcat3

+0

你可以使用這個// lettertype [類型/ @ ID =「個人」] [類型=「檢查」] – Rupesh

+0

srry沒有工作。我有。我基本上要禁用與也許的單選按鈕 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t的停用 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t – topcat3