If you're calling your XSLT transformation from Javascript and it's the calling program that computes the ID, then declare a stylesheet parameter <xsl:param name="id"/> and refer to it as select="//child[@id=$id]"; you can set the parameter from the calling Javascript code using a method in the API defined by your chosen XSLT processor, typically something like transformer.addParameter("id", "a1234").
Alternatively, if your XSLT processor supports it, you can call Javascript extension functions. In Microsoft's MSXML processor (and also in their .NET processor) you can write these within an <msxsl:script> element as shown in another answer to your post.
On the other hand, you might be thinking in terms of Javascript within the HTML page activated by the user clicking a button or similar. If so, you've got things wrong: the XSLT transformation can never respond directly to user interface events.
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference