如何通过选中复选框以XSL格式添加动态值?我将发布我的XLS表单代码

时间:2011-12-18 16:52:44

标签: xslt

如何通过选中复选框以XSL格式添加动态值?我想在选中复选框时显示Grosspremium值。如果我选​​择两个复选框,则显示Grosspremium总数。我是XSL的新手。这里的值来自数据库。

以下是XSL表单代码。

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="enquiry.action"/>
<xsl:param name="Agent.Code" />
<xsl:param name="Agent.Date" />
<xsl:template match="/">
<html>
<title>mission</title>
<script type="text/javascript">
function test(obj)
{
<xsl:for-each select="SubDetails/Table">
<xsl:value-of select="GrossPremium"></xsl:value-of>
<xsl:value-of select="StampDuty"></xsl:value-of>
<xsl:value-of select="CommissionAmount"></xsl:value-of>
<xsl:value-of select="GrossAmountPayable"></xsl:value-of>
<xsl:value-of select="NetAmountPayable"></xsl:value-of>

</xsl:for-each>
}

</script>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

<table border="0" width="990" cellspacing="0" cellpadding="0">
<tr valign="top">
<!--<td align="center">
<table width="990" border="0" cellspacing="0" cellpadding="0">
<tr>-->
<td>
<div id="MainDev" style="width: 615px; height: 148px">
<table style="border-style: none; width: 997px; font-family: 'Times New Roman', Times, serif; font-size: medium; font-weight: bold; font-style: normal; font-variant: normal; text-transform: none; color: #000000; visibility: visible; table-layout: fixed; empty-cells: hide;">
<tr>
<td style="text-align:left;" class="interiortext">
example No:
</td>
</tr>
</table>

<input id="Btnexample1" type="button" value=".btn example" style="font-family:
'Times New Roman', Times, serif; font-size: medium; font-weight: bold; font-style: normal;
font-variant: normal; text-transform: none;
color: #000000; text-decoration: underline; border: thin groove #008080; background-color: #FFFFFF;
text-align: left; width: 995px; white-space: normal; word-spacing: normal; letter-spacing: normal;
vertical-align: baseline" onclick="return setVisibility('btnexample');" />
<div id="MotorSubmission">
<table style="border-style:none; width: 997px; font-family: 'Times New Roman',
Times, serif; font-size: medium; font-weight: bold;
font-style: normal; font-variant: normal; text-transform: none; color: #000000;
visibility: visible; table-layout: fixed;">
<tr bgcolor="#C48793">
<td>Select</td>
<td>Cover Note Date</td>
<td>Cover Note No</td>
<td>Insured Name</td>
<td>Vehicle No</td>
<td>NCD%</td>
<td>Gross Premium</td>
<td>Service Tax</td>
<td>Stamp Duty</td>
<td>Gross Amount Payable</td>
<td>Commission</td>
<td>Net Amount Payable</td>

</tr>
<xsl:choose>
<xsl:when test="count(SubDetails/Table)>0">
<xsl:for-each select="SubDetails/Table">
<!--<table style="padding: inherit; margin: inherit; border: thin solid #808080;     width:100%; list-style-type: square; list-style-image: inherit; list-style-position: inside;">-->`
<tr>
<td align="center">
<!--<input type="CheckBox" Name="cb1" onclick="toggle(this,'myGroup')">-->
<input type="checkbox" name="Checkbox" onclick="test('abc')"></input>
</td>
<td>
<xsl:value-of select="Date"/>
</td>
<td>
<xsl:value-of select="CoverNoteNumber"/>
</td>
<td>
<xsl:value-of select="IssuedName"/>
</td>
<td>
<xsl:value-of select="VehicleNumber"/>
</td>
<td>
<xsl:value-of select="NCDPercentage"/>
</td>
<td>
<xsl:value-of select="GrossPremium"/>
</td>
<td>
<xsl:value-of select="ServiceTaxPercentage"/>
</td>
<td>
<xsl:value-of select="StampDuty"/>
</td>
<td>
<xsl:value-of select="GrossAmountPayable"/>
</td>
<td>
<xsl:value-of select="CommissionAmount"/>
</td>
<td>
<xsl:value-of select="NetAmountPayable"/>
</td>
</tr>
</xsl:for-each>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<input type="label" id="GrossTotal" name="Label"></input>
</td>
<td></td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</xsl:when>
</xsl:choose>
</table>
</div>
<input id="btnnonmotor" type="button" value=".Non-Motor Submission" style="font-family: 'Times New Roman', Times, serif; font-size: medium; font-weight: bold; font-style: normal; font-variant: normal; text-transform: none; color: #000000; text-decoration: underline; border: thin groove #008080; background-color: #FFFFFF; text-align: left; width: 995px; white-space: normal; word-spacing: normal; letter-spacing: normal; vertical-align: baseline"
onclick="return setVisibility('Nonexample2')" />
<div id="NonMotorSubmission" style="display:none">
<table style="border-style:none; width:990px; font-family: 'Times New Roman', Times, serif; font-size: medium; font-weight: bold; font-style: normal; font-variant: normal; text-transform: none; color: #000000; visibility: visible; table-layout: fixed;">
<tr bgcolor="#C48793">
<td>Select</td>
<td>Cover Note Date</td>
<td>Cover Note No</td>
<td>Insured Name</td>
<td>Gross Payment</td>
<td>Service Tax</td>
<td>Stamp Duty</td>
<td>GrossAmountPayable</td>
<td>Commission</td>
<td>Net Amount Payable</td>
</tr>
<xsl:choose>
<xsl:when test="count(Details/Table)>0">
<xsl:for-each select="Details/Table">
<!--<table style="padding: inherit; margin: inherit; border: thin solid #808080; width:100%; list-style-type: square; list-style-image: inherit; list-style-position: inside;">-->
<tr>
<td>
<input type="CheckBox" id="CheckboxId2" name="CheckBox2" value="Checked">
</input>
</td>
<td>
<xsl:value-of select="CoverNoteDate"/>
</td>
<td>
<xsl:value-of select="CoverNoteNo"/>
</td>
<td>
<xsl:value-of select="InsuredName"/>
</td>
<td>
<xsl:value-of select="GrossPremium"/>
</td>
<td>
<xsl:value-of select="ServiceTax"/>
</td>
<td>
<xsl:value-of select="STAMPDUTY"/>
</td>
<td>
<xsl:value-of select="GROSSAMOUNT_x0020_PAYABLE"/>
</td>
<td>
<xsl:value-of select="COMMISION_AMOUNT"/>
</td>
<td>
<xsl:value-of select="NETAMOUNTPAYABLE"/>
</td>
</tr>
</xsl:for-each>
<tr>
<td></td>
<td></td>
<td></td>
<td align="center">TOTAL</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</xsl:when>
</xsl:choose>
</table>
</div>
<table style="border-style:none; width: 997px;font-family: 'Times New Roman', Times, serif; font-size: medium; font-weight: bold; font-style: normal; font-variant: normal; text-transform: none; color:white; visibility: visible; table-layout: fixed;">
<tr bgcolor="#7AB8B8">
<td>payment Mode</td>
<td>Cheque No/Credit Card No</td>
<td>Gross Payable(RM)</td>
<td>Thick</td>
<td>NettPayable(RM)</td>
<td>Thick</td>
</tr>
<tr>
<td>
<select id="ddlPaymentMode" style="width:150px;">
<option value="Select">--Select--</option>
<option value="Cash">Cash</option>
<option value="Cheque">Cheque</option>
<option value="CreditCard">Credit Card</option>
<option value="E-Payment">E-Payment</option>
</select>
</td>
<td>
<input id="TxtChequeno" type="text" />
</td>
<td>
<input id="TxtGrossPayable" type="text" />
</td>
<td>
<input id="Checkbox1" type="CheckBox" />
</td>
<td>
<input id="TxtNettPayable" type="text" />
</td>
<td>
<input id="Checkbox1" type="CheckBox" />
</td>
</tr>
</table>

<input id="Button1" type="button" value="SUBMIT"
style="font-family: 'Times New Roman', Times, serif; font-size: medium; font-weight: bold; text-align: center; width: 91px; margin-left: 904px" />
<br />
</div>
</td>
</tr>
</table>
<!--</td>
</tr>
</table>-->
   <table  width="100%" border="0" cellspacing="0" cellpadding="0">
<tr style="background-color: #D3D9D9">
<td valign="top">
   </td>
</tr>
<!--<tr background="Images/home_main.gif">
<td align="right">
   </td>
</tr>-->
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

2 个答案:

答案 0 :(得分:0)

点击复选框,将position()行传递给test()功能。

类似这样的内容,test(3)test(6)test(7),......很快

根据position(),您可以执行<xsl:for-each>并检查position()是否等于测试函数的参数变量的条件。如果是,则添加<xsl:value-of select="GrossPremium" />值。

试试这种方式......

答案 1 :(得分:0)

我按照以下方式做了,我得到了一些像对象一样的错误。请做一些必要的修改。

<xsl:comment>
          var chb = new Array()
          <xsl:for-each select="SubDetails/Table">
            chb[<xsl:value-of select="position()"/>] = "<xsl:value-of select="@chb"/>"
          </xsl:for-each>
          function doselect(i)
          {
          select(chb[i])
          }
          <xsl:for-each select="SubDetails/Table">
            chb="javascript: doselect({position()})">
            <xsl:value-of select="Name"/>
          </xsl:for-each>
        </xsl:comment></script>