怎样取得多行中当前行的值?

我的xml和xsl文件如下:

lz.xml:

 1<cd>
 2<st>
 3<data>
 4<row staff="2323233"></row>
 5<row staff="464646"></row>
 6<row staff="6767"></row>
 7<row staff="9000"></row>
 8</data>
 9</st>
10</cd>

lz.xsl:

 1<xsl:stylesheet result-ns="" xmlns="http://www.w3.org/TR/REC-html40" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
 2<xsl:template><xsl:apply-templates></xsl:apply-templates></xsl:template>
 3<xsl:template match="/">
 4<html>
 5<head>
 6<script language="JavaScript1.2">
 7</script>
 8<title></title>
 9</head>
10<body>
11<xsl:apply-templates select="CD/ST"></xsl:apply-templates>
12</body>
13</html>
14</xsl:template>
15<xsl:template match="ST">
16<form action="" method="post" name="form1">
17<body>
18<table border="2" cellpadding="0" cellspacing="1" width="42%">
19<tr>
20<td width="15%"><div align="center"><font face="宋体" size="2"></font></div></td>
21<td width="85%"><div align="center"><font face="宋体" size="2">员工号</font></div></td>
22</tr>
23<xsl:for-each select="DATA/ROW">
24<tr>
25<td><div align="center"><font face="宋体" size="2">
26<input name="Submit" style="width:16;" type="submit" value="√"/>
27</font></div><xsl:element name="input">
28<xsl:attribute name="name">RETURN</xsl:attribute>
29<xsl:attribute name="type">hidden</xsl:attribute>
30<xsl:attribute name="value"><xsl:value-of select="@staff"></xsl:value-of><!--这里要取得当前行的值,点击“√”按钮,每次只提交一个值即当前行的staff值 ;现在每次提交的值为多个,并且取得不了staff的值--></xsl:attribute>
31</xsl:element>
32</td>
33<td><div align="center"><font face="宋体" size="2"><xsl:value-of select="@staff"></xsl:value-of></font></div></td>
34</tr>
35</xsl:for-each>
36</table>
37</body>
38</form>
39</xsl:template>
40</xsl:stylesheet>

要实现点击“√”按钮,每次只提交一个值即当前行的staff值 ;现在每次提交的值为多个,并且取得不了staff的值,请各位大侠帮忙看看,多谢!
---------------------------------------------------------------

>>>每次只提交一个值即当前行的staff值

not possible, since you declare them to be

1<input/>

, you could add an additional

1<input type="hidden"/>

and do something like

 1<form action="" method="post" name="form1">
 2<input name="selectedItem" type="hidden" value=""/>   
 3....   
 4<input name="Submit" style="width:16;" type="submit" value="√"/>
 5<xsl:attribute name="onclick">this.form.selectedItem.value='<xsl:value-of select="@staff"></xsl:value-of>'</xsl:attribute>   
 6  
 7  
 8or use a SELECT instead   
 9  
10<select name="RETURN" style="visibility:hidden">
11<xsl:for-each select="DATA/ROW">
12<option>
13<xsl:attribute name="value"><xsl:value-of select="@staff"></xsl:value-of></xsl:attribute>
14</option>
15</xsl:for-each>
16</select>
17<xsl:for-each select="DATA/ROW">
18<tr>
19<td><div align="center"><font face="宋体" size="2">
20<input name="Submit" style="width:16;" type="submit" value="√"/>
21<xsl:attribute name="onclick">this.form.RETURN.selectedIndex=<xsl:eval>childNumber(this)-1</xsl:eval></xsl:attribute>
22</font></div>
23</td>
24<td><div align="center"><font face="宋体" size="2"><xsl:value-of select="@staff"></xsl:value-of></font></div></td>
25</tr>
26</xsl:for-each></form>
Published At
Categories with Web编程
comments powered by Disqus