在javascript中获取xsl值并检查0到99 [英] get xsl value in javascript and check for 0 to 99
问题描述
我有以下xsl面板,这些面板是根据用户选择产品而创建的。用户可以选择最多99个和99个精确的以下代码面板。我有jQuery代码来处理(显示/隐藏)输入字段,当从下拉列表中选择其他。
基本上我试图抓住xsl id我的JavaScript,所以我可以将代码应用到我的ID,这将相应地增加。
任何帮助非常感谢。
< xsl:attribute name =id> panel22_< xsl: select =@ id/>< / xsl:attribute>的值
var one = document.getElementById('< xsl:value-of select =@ id/>')
$('#producttypes'+'_'+ one).change函数()
{
if($('#otherprodtype')。(':selected'))
{
$('#myotherbox')。show() ;
}
else
{
if($('#'myotherbox')。is(':visible'))
{
$(' #myotherbox')。hide();
}
}
});;
< / script>
< tr>
< td class =标签>产品类型< / td>
< td class =field>
< select name =producttypesid =producttypes_< xsl:value-of select =@ id/>>
< option value =domguar>
< xsl:if test =producttypes / option [@ id ='domguar'] ='selected'>
< / xsl:if>国内担保< / option>
< option value =indemnity>
< xsl:if test =producttypes / option [@ id ='indemnity'] ='selected'>
< / xsl:if>赔偿金< / option>
< option value =domcontbond>
< xsl:if test =producttypes / option [@ id ='domcontbond'] ='selected'>
< / xsl:if>国内合约债券< / option>
< option value =perfbond>
< xsl:if test =producttypes / option [@ id ='perfbond'] ='selected'>
< / xsl:if> Performance Bond< / option>
< option value =interventionguar>
< xsl:if test =producttypes / option [@ id ='interventionguar'] ='selected'>
< / xsl:if>干预保证< / option>
< option value =customsguar>
< xsl:if test =producttypes / option [@ id ='customsguar'] ='selected'>
< / xsl:if>海关保证< / option>
< option value =vatbond>
< xsl:if test =producttypes / option [@ id ='vatbond'] ='selected'>
< / xsl:if> VAT Bond< / option>
< option value =otherprodtypeid =otherprodtype_< xsl:value-of select =@id/>>
< xsl:if test =producttypes / option [@ id ='otherprodtype'] ='selected'>
< / xsl:if>其他< / option>
< / select>
< td class =fieldid =myotherbox_< xsl:value-of select =@ id/>风格= 显示:无; >
< input class =amdInputTexttype =textid =otherprodtypeboxvalue =style =display:none;>
< xsl:attribute name =value>< xsl:value-of select =otherprodtypebox>< / xsl:value-of>< / xsl:attribute>< / input> ;
< / td>
< / td>
< / tr>
我认为您在以下行中遇到问题
< select name =producttypesid =producttypes_< xsl:value-of select =@ id/> >
并且在关联的表单元格中
< td class =fieldid =myotherbox_< xsl:value-of select =@ id/>风格= 显示:无; >
这显然是无效的XSLT语法。但是恐慌不是,有一个直接的方法来做到这一点,那就是使用属性值模板。只需将您的select语句更改为此
< select name =producttypesid =producttypes _ {@ id}>
大括号表示这是一个要评估的表达式,而不是字面输出。希望它应该像这样输出(假设@id设置为123,例如)
< select name =producttypes id =producttypes_123>
您可以用类似的方式修改表格单元。
I have the following xsl panels that are created depending on the user selecting a product. The user can select a maximum of 99 and 99 exact panels of the code below will be produced. I have jQuery code to manipulate (show/hide) an input field when 'Other' is selected from the dropdown.
Basically I'm trying to grab the xsl id in my javascript so I can apply the code to my id's which will be incremented accordingly.
Any help much appreciated. The errors relate to illegal argument in the javacript.
<xsl:attribute name="id">panel22_<xsl:value-of select="@id"/></xsl:attribute>
<table border="0" width="100%" height="100%" bgcolor="lightyellow" class="inline"
<script type="text/javascript">
var one = document.getElementById('<xsl:value-of select="@id"/>')
$('#producttypes' + '_' + one).change(function()
{
if($('#otherprodtype').is(':selected'))
{
$('#myotherbox').show();
}
else
{
if($('#myotherbox').is(':visible'))
{
$('#myotherbox').hide();
}
}
});;
</script>
<tr>
<td class="Label">Product Type</td>
<td class="field">
<select name="producttypes" id="producttypes_<xsl:value-of select="@id"/>">
<option value="domguar">
<xsl:if test="producttypes/option[@id='domguar']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Domestic Guarantee</option>
<option value="indemnity">
<xsl:if test="producttypes/option[@id='indemnity']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Indemnity</option>
<option value="domcontbond">
<xsl:if test="producttypes/option[@id='domcontbond']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Domestic Contract Bond</option>
<option value="perfbond">
<xsl:if test="producttypes/option[@id='perfbond']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Performance Bond</option>
<option value="interventionguar">
<xsl:if test="producttypes/option[@id='interventionguar']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Intervention Guarantee</option>
<option value="customsguar">
<xsl:if test="producttypes/option[@id='customsguar']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Customs Guarantee</option>
<option value="vatbond">
<xsl:if test="producttypes/option[@id='vatbond']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>VAT Bond</option>
<option value="otherprodtype" id="otherprodtype_<xsl:value-of select="@id"/>">
<xsl:if test="producttypes/option[@id='otherprodtype']='selected'">
<xsl:attribute name="selected"/>
</xsl:if>Other</option>
</select>
<td class="field" id="myotherbox_<xsl:value-of select="@id"/>" style="display:none;">
<input class="amdInputText" type="text" id="otherprodtypebox" value="" style="display:none;">
<xsl:attribute name="value"><xsl:value-of select="otherprodtypebox"></xsl:value-of></xsl:attribute></input>
</td>
</td>
</tr>
I think you have your problems in the following line
<select name="producttypes" id="producttypes_<xsl:value-of select="@id"/>">
And also in the associated table cell
<td class="field" id="myotherbox_<xsl:value-of select="@id"/>" style="display:none;">
This is obviously not valid XSLT syntax. But panic ye not, there is an straight-forward way to do this, and that is to use Attribute Value Templates. Just change your select statement to this
<select name="producttypes" id="producttypes_{@id}">
The curly braces indicate this is an expression to be evaluated, rather than output literally. Hopefully it should be output like so (assuming @id is set to 123, for example)
<select name="producttypes" id="producttypes_123">
You would amend the table cell in a similar manner.
这篇关于在javascript中获取xsl值并检查0到99的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!