在xsl中我从数据库中得到一数据
循环判断,并分割数据后进行判断,有对应值则复选下拉框选中
例如:
数据库得到的数据 Resource/WorkType=“需求,编码”
判断数据是否有(以‘,’隔开)
<select id="sltediteWeek" multiple="true" style="width:150">
<option value="">[请选择]</option>
<option value="需求">
<xsl:if test="substring(Resource/WorkType,0,3)='需求'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>需求
</option>
<option value="编码">
<xsl:if test="Resource/WorkType='编码'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>编码
</option>
<option value="设计">
<xsl:if test="Resource/WorkType='设计'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>设计
</option>
<option value="测试">
<xsl:if test="Resource/WorkType='测试'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>测试
</option>
</select>效果:需求,编码。都选中
循环判断,并分割数据后进行判断,有对应值则复选下拉框选中
例如:
数据库得到的数据 Resource/WorkType=“需求,编码”
判断数据是否有(以‘,’隔开)
<select id="sltediteWeek" multiple="true" style="width:150">
<option value="">[请选择]</option>
<option value="需求">
<xsl:if test="substring(Resource/WorkType,0,3)='需求'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>需求
</option>
<option value="编码">
<xsl:if test="Resource/WorkType='编码'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>编码
</option>
<option value="设计">
<xsl:if test="Resource/WorkType='设计'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>设计
</option>
<option value="测试">
<xsl:if test="Resource/WorkType='测试'">
<xsl:attribute name="selected">true</xsl:attribute>
</xsl:if>测试
</option>
</select>效果:需求,编码。都选中
写一个正则表达式,去掉最后一个‘,’
结果为:str="abc,eft,tt,cc";这个帮我作出来了也给分
截掉逗号为什么不用substring?如果非用正则:str.replace(/,$/, "")
注:里面使用到了contains这个函数。