2012-12-12 50 views
1

XML:如何將兩個函數放在一個onclick屬性中? XSLT

<CONTROLS> 
     <BUTTON> 
       <input name="myButton" onclick="existingFunction();"/> 
     </BUTTON> 
     <LABEL> 
       Text ME 
     </LABEL> 

    </CONTROLS> 

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output omit-xml-declaration="yes" indent="yes"/> 

<xsl:template match="input"> 
    <input onclick="{@onclick}newFunction();"> 
     <xsl:copy-of select="@*[not(name()='onclick')]"/> 
    </input> 
</xsl:template> 

</xsl:stylesheet> 

我怎樣才能把兩種功能於一體onclick屬性?

結果:

<input onclick="existingFunction();newFunction();" name="myButton"/> 

它不工作。有沒有其他的方式來合併這兩個功能?

我不想把函數2函數內部1. :)

+0

是什麼'它不是working'究竟意味着什麼呢?你的意思是'onclick'的實際功能嗎? –

回答

1

備選答案:

通話功能3()在onClick事件..這看起來像

function function3() 
{ 
    function1(); 
    function2(); 
} 
+0

@丹尼爾是的,當按鈕被點擊時,兩個功能不會執行 – iCeR

+2

你在錯誤的地方發表評論! –

0

將這樣的事情對你的工作?

onclick="function baz(){foo(); bar();} baz();" 
// or 
onclick="(foo(); bar(); baz(); derp(); ...)()"; 
相關問題