获得价值

时间:2011-06-23 14:01:46

标签: javascript html xslt

我有以下代码:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:hi="http://www.******.nl" version="1.0">

<xsl:output method="html" indent="yes" />
<xsl:param name="bdr" />
<xsl:param name="intsrtlg" />
<xsl:param name="intsrtgr" />
<xsl:param name="var1" />
<xsl:param name="t" />
<xsl:param name="oms" />

<xsl:template match="/">

<script language="Javascript">
function addCart(artNr){
    document.cartForm.artNr.value = artNr;
    document.cartForm.aantalArts.value = aantalArts;
    document.cartForm.submit();
}
</script>
<div style="margin-left:10px"><span class="bestelart">B</span> = Bestelartikel</div>
<table border="0" cellspacing="10" cellpadding="0" class="kop_toppers" width="100%">
<tr><td width="50">Art.Nr.</td><td width="400">Omschrijving</td><td width="25">VP</td><td width="100" align="center">Prijs (ex. btw)</td><td width="50">Aantal</td><td width="75"></td></tr></table>
<table border="0" cellspacing="5" cellpadding="0" width="100%">
<xsl:for-each select="//regels/item">
<xsl:value-of select="hi:getKop()" disable-output-escaping="yes" />
<td valign="top" height="100%">
<table cellspacing="2" cellpadding="0" class="toppersTable" width="100%" height="100%"><tr>

        <td width="50"><xsl:value-of select="veld[3]" /><span class="bestelart"><xsl:value-of select="veld[34]" /></span></td>
        <td width="400px"><span class="bold">
        <xsl:value-of select="hi:replOms(string(veld[4]))" />  
        <xsl:value-of select="hi:replOms(string(veld[5]))" />  
        <xsl:value-of select="hi:replOms(string(veld[6]))" />
        </span></td>
        <td width="25">(<xsl:value-of select="veld[9]" />)</td>
        <td align="center" width="100"><span class="prijsEx"><xsl:text disable-output-escaping="yes">&amp;</xsl:text>euro;<xsl:value-of select="veld[7]" /></span></td>
        <td width="50"><input type="text" size="3" value="1" name="aantalArts" id="aantalArts" class="infoButton" /></td>
        <td width="75"><input type="button" value="Bestellen" class="infoButton" onclick="addCart('{veld[3]}'),**FIELD**" /></td>
        </tr>
        </table>
    </td>
    <xsl:value-of select="hi:getBottom()" disable-output-escaping="yes" />
</xsl:for-each>
</table>

<form name="cartForm" method="post" action="addcart.asp">
    <input type="hidden" name="act" value="add" />
    <input type="hidden" name="artNr" value="" />
    <input type="hidden" name="aantalArts" value="" />
</form>

</xsl:template>
<msxsl:script language="JScript" implements-prefix="hi">
<![CDATA[

function getMonth(){
    var maanden = ["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"];
    var d = new Date();
    var month = maanden[d.getMonth()].toUpperCase();
    return month;
}

var teller = 0;
function getKop(){
    var returnStr = '';
    if(teller==0){
        returnStr = '<tr>';
    }
    teller++;
    return returnStr;
}

function getBottom(){
    var returnStr = '';
    if(teller==1){
        returnStr = '</tr>';
        teller=0;
    }
    return returnStr;
}

function replOms(oms){
    oms = oms.replace(/&#160;/g," ");
    return oms;
}
]]></msxsl:script>

</xsl:stylesheet>

如何将输入值AantalArts输入标有**FIELD**的地方?

2 个答案:

答案 0 :(得分:3)

更新了评论中的XSLT信息&amp;正确拼写功能

您可以使用document.getElementById()

<input type="text" size="3" value="1" name="aantalArts_{position()}" id="aantalArts_{position()}" class="infoButton" />
<input type="button" value="Bestellen" class="infoButton" onclick="addCart('{veld[3]}', document.getElementById('aantalArts_{position()}').value)" />

答案 1 :(得分:1)

的document.getElementById( 'aantalArts')。值