开发者

button in XSL for AJAX usage

I wonder if its is possible to do AJAX when I put a button inside the xsl file;

<input type = "button" id="laptop" value = "Add to Cart" onclick="sendCartRequest('Add');" />

That's w开发者_JAVA技巧hat I do in my xsl file then in my js file I pass the id to the DOM and try to alert it make sure it is passed. And the alert appear to be empty.

Is it a mistake to put the button in the xsl? or that's something else that cause it's empty? May be my DOMpath?

Please point me a right direction.

Thanks in advance.


If you have more than one <input>on the page, then you might want to try generating the id field: <input type="button">
<xsl:attribute name="id">laptop_<xsl:value-of select="generate-id()"/></xsl:attribute>
<xsl:attribute name="onclick">sendCartRequest('add',this)</xsl:attribute>
</input>

in your javascript sendCartRequest method, note that I have added a "this" parameter. Inside this function you can retrieve which button was clicked by examining the id attribute.

If the id attribute uses a product id or something that is used from the xml, even easier to send the transaction.

comment on my response if you need more details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜