Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reference XML items from a Javascript function directly

Status
Not open for further replies.

adhp55555

Programmer
Oct 24, 2003
9
US
Hi everyone, please help!!!
In order to display data in a popup window coded in a XSLT stylesheet, I created a javascript function, called PopupWindow(xmlTag, ddnnum) as follows:
function PopUpWindow(xmlTag,ddnnum)
{
ExtraWin = window.open("", "_blank", config='width=500,height=300,left=200,top=150');
ExtraWin.document.write(&quot;DDN Number : &quot; + ddnnum + &quot;<br></br>&quot;);
ExtraWin.document.write(&quot;XML Tag : &quot; + xmlTag);
}

And the XSLT statement to evoke this function as follows:
<td><a><xsl:attribute name=&quot;href&quot;>Javascript:popUpWindow(&quot;<xsl:value-of select=&quot;FIELDXMLTAG&quot;/>&quot;,<xsl:value-of select=&quot;FIELDDDN&quot;/>)</xsl:attribute><xsl:value-of select=&quot;FIELDDDN&quot;/></a></td>

In this XSLT statement, I passed values of FIELDXMLTAG and FIELDDDN to the function. In case I want to display 20 fields or more in the popup window, I must pass 20 values or more of XML fields to the function. It is cumbersome; therefore we need to have a way to directly reference XML fields from the &quot;popupwindow&quot; Javascript function without receiving values passed from the XSLT calling statement. Anybody knows how to do it so that the XSLT calling statement doesn't need to pass values to shorten the statement as follows:
<td><a><xsl:attribute name=&quot;href&quot;>Javascript:popUpWindow()</a></td>
To be specific, how do I change the write statement in the Javascript function: PopUp Window() to display two fields:
FIELDDDN and FIELDXMLTAG when values of those two fields are no longer passed to the Javascript function.

Thank you
 

You should be able to use window.opener.variableName to refer to a variable defined in the parent (opener) window.

Hope this helps!

Dan
 
Hi BillyRayPreacherSon,
Thank you BillyRayPreacherSon, but variables that I want to display their values in the popup window are tag names of XML data stored on HTML data island of the parent window (ASP). Therfore, how do I specify which value? How're about their specific row and column? Please shed more light to me on this matter. My XSLT display them in a HTML table with the code as follows:

<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>

<tr class=&quot;headrow&quot;>
<td></td>
<td><b><u>Fld ID</u></b></td>
<td><b><u><a href=&quot;RBMain.asp?referringPage=SortedFromColRB&quot; title=&quot;Sorted by From-Col&quot;>From Col</a></u></b></td>
<td><b><u> To Col</u></b></td>
<td><b><u> Size</u></b></td>
<td><b><u> Format</u></b></td>
<td><b><u><a href=&quot;RBMain.asp?referringPage=SortedRedBookRB&quot; title=&quot;Sorted by RedBook Name&quot;>RedBook Name</a></u></b></td>
<td><b><u><a href=&quot;RBMain.asp?referringPage=SortedFMCodeRB&quot; title=&quot;Sorted by FM Code&quot;>FM Code</a></u></b></td>
<td><b><u><a href=&quot;RBMain.asp?referringPage=SortedDDNRB&quot; title=&quot;Sorted by DDN&quot;>DDN</a></u></b></td>
</tr>

<xsl:for-each select=&quot;MASTER/DOCUMENT&quot;>

<xsl:choose>
<xsl:when test=&quot;EXTRAINFOFLAG &gt; 0&quot;>
<tr>
<td><a><xsl:attribute name=&quot;href&quot;>javascript:ShowHide(<xsl:value-of select=&quot;FIELDID&quot;/>,<xsl:value-of select=&quot;EXTRAINFOFLAG&quot;/>)</xsl:attribute><img src=&quot;buttonclosed.gif&quot;><xsl:attribute name=&quot;name&quot;>openclosepic<xsl:value-of select=&quot;FIELDID&quot;/></xsl:attribute></img></a></td>
<td><xsl:value-of select=&quot;FIELDID&quot;/></td>
<td><xsl:value-of select=&quot;FROMCOL&quot;/></td>
<td><xsl:value-of select=&quot;TOCOL&quot;/></td>
<td><xsl:value-of select=&quot;FIELDSIZE&quot;/></td>
<td><xsl:value-of select=&quot;FIELDFORMAT&quot;/></td>
<td><xsl:value-of select=&quot;FIELDNAME&quot;/></td>
<td><xsl:value-of select=&quot;FMCODE&quot;/></td>
<td><a><xsl:attribute name=&quot;href&quot;>Javascript:popUpWindow(&quot;<xsl:value-of select=&quot;FIELDXMLTAG&quot;/>&quot;,<xsl:value-of select=&quot;FIELDDDN&quot;/>)</xsl:attribute><xsl:value-of select=&quot;FIELDDDN&quot;/></a></td>
</tr>
</xsl:when>
<xsl:eek:therwise>
<xsl:choose>
<xsl:when test=&quot;FIELDDOC &gt; 0&quot;>
<tr style=&quot;display: none&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;><xsl:attribute name=&quot;id&quot;>MoreInfo<xsl:value-of select=&quot;FIELDID&quot;/><xsl:value-of select=&quot;FIELDDOC&quot;/></xsl:attribute>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><font color=&quot;red&quot;><xsl:value-of select=&quot;FIELDNAMEDOC&quot;/></font></td>
</tr>
</xsl:when>
<xsl:eek:therwise>
<tr>
<td></td>
<td><xsl:value-of select=&quot;FIELDID&quot;/></td>
<td><xsl:value-of select=&quot;FROMCOL&quot;/></td>
<td><xsl:value-of select=&quot;TOCOL&quot;/></td>
<td><xsl:value-of select=&quot;FIELDSIZE&quot;/></td>
<td><xsl:value-of select=&quot;FIELDFORMAT&quot;/></td>
<td><xsl:value-of select=&quot;FIELDNAME&quot;/></td>
<td><xsl:value-of select=&quot;FMCODE&quot;/></td>
<td><a><xsl:attribute name=&quot;href&quot;>Javascript:popUpWindow(&quot;<xsl:value-of select=&quot;FIELDXMLTAG&quot;/>&quot;,<xsl:value-of select=&quot;FIELDDDN&quot;/>)</xsl:attribute><xsl:value-of select=&quot;FIELDDDN&quot;/></a></td>
</tr>
</xsl:eek:therwise>
</xsl:choose>
</xsl:eek:therwise>
</xsl:choose>
</xsl:for-each>

</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top