使用.addParameter()函数 [英] Using the .addParameter() function

查看:98
本文介绍了使用.addParameter()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个下拉列表,当我选择了某些内容时,我就明白了这一点

从下拉列表中调用了一个JavaScript函数。我希望它如此

从下拉列表中选择的值作为参数发送到xslt文件的

。当我从下拉列表中选择一个值时,不会出现
。我想要一个标题,图像和描述的基本列表

outputed。我已经完成了一个使用.write()

函数的基本JavaScript,这样就可以从下拉列表中将值发送到

JavaScript函数。所以使用.addParameter函数必须是

。我能错过什么?


这是我的javascript和下拉菜单。

< body MS_POSITIONING =" FlowLayout">

< form id =" Form1"方法= QUOT;交" runat =" server">

< SELECT name =" select1" onchange =''CallXML(this.form.select1);''>

< OPTION value =" Ratchet and Clank"> Ratchet and Clank< / OPTION>

< OPTION value =" Sly Cooper"> Sly Cooper< / OPTION>

< / SELECT>

< / form>

< / body>


< script language =" javascript">

函数CallXML(下拉列表)

{

var myindex = dropdown.selectedIndex;

var SelValue = dropdown.options [myindex] .value;

xml = new ActiveXObject(" Msxml2.DOMDocument.4.0");

xml.async = false;

xml.load(" Games.xml" );

xslt = new ActiveXObject(" Msxml2.FreeThreadedDOMDocument.4.0");

xslt.async = false;

xslt。 load(" Games.xslt");

xslTemp = new ActiveXObject(" Msxml2.XSLTemplate.4.0");

xslTemp.stylesheet = xslt;

var xslProc = xslTemp.createPr ocessor();

xslProc.input = xml;

xslProc.addParameter(Title,SelValue);

xslProc.transform;

xslProc.output;

}

< / script>


这是我的xslt文件。

<?xml version =" 1.0" encoding =" ISO-8859-1"?>

< xsl:stylesheet version =" 1.0"

xmlns:xsl =" http:/ /www.w3.org/1999/XSL/Transform"

xmlns:lc =" http:// mark / DevelopmentWebsite">

< xsl:output method =" html" />

< xsl:param name =" Title" />

< xsl:template match =" /" ;>


< h2>我的游戏合集< / h2>

< table border =" 1">

< xsl:for-each select =" lc:Entertainment / lc:GameList [lc:Title =

$ Title]">

< ; tr>

< th colspan =" 2">< xsl:value-of select =" lc:Title" />< / th>

< / tr>

< tr>

< td>

< xsl:element name =" IMG" ;>

< xsl:attribute name =" SRC">

< xsl:value-of select =" lc:Image" />

< / xsl:attribute>

< / xsl:element>

< / td>

< td>< xsl:value-of select =" lc:描述" />< / td>

< / tr>

< / xsl:for-each>

< / table>


< / xsl:template>

< / xsl:stylesheet>

I have a drop-down list now and I got it so when something is selected
from the drop down list it calls a JavaScript function. I want it so
the value selected from the drop-down list is sent as a parameter to
the xslt file. When I select a value from the drop-down list nothing
appears. I want just a basic listing of Title, Image, and Description
outputed. I have done a basic JavaScript that uses the .write()
function and that worked so the value is getting sent to the
JavaScript function from the drop-down list. So the problem has to be
with the .addParameter function. What could I be missing?

Here is my javascript and drop-down menu.
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<SELECT name="select1" onchange=''CallXML(this.form.select1);''>
<OPTION value="Ratchet and Clank">Ratchet and Clank</OPTION>
<OPTION value="Sly Cooper">Sly Cooper</OPTION>
</SELECT>
</form>
</body>


<script language="javascript">
function CallXML(dropdown)
{
var myindex = dropdown.selectedIndex;
var SelValue = dropdown.options[myindex].value;
xml = new ActiveXObject("Msxml2.DOMDocument.4.0");
xml.async = false;
xml.load("Games.xml");
xslt = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0" );
xslt.async = false;
xslt.load("Games.xslt");
xslTemp = new ActiveXObject("Msxml2.XSLTemplate.4.0");
xslTemp.stylesheet = xslt;
var xslProc = xslTemp.createProcessor();
xslProc.input = xml;
xslProc.addParameter(Title, SelValue);
xslProc.transform;
xslProc.output;
}
</script>

Here is my xslt file.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lc="http://mark/DevelopmentWebsite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Entertainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xsl:value-of select="lc:Title"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribute name="SRC">
<xsl:value-of select="lc:Image"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:value-of select="lc:Description"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

推荐答案

Title]">

< tr>

< th colspan =" 2">< xsl:value -of select =" lc:Title" />< / th>

< / tr>

< tr>

< td>

< xsl:element name =" IMG">

< xsl:attribute name =" SRC">

< xsl:value-of select =" lc:Image" />

< / xsl:attribute>

< / xsl :element>

< / td>

< td>< xsl:value-of select =" lc:Description" />< / td> ;

< / tr>

< / xsl:for-each>

< / table>


< / xsl:template>

< / xsl:stylesheet>
Title]">
<tr>
<th colspan="2"><xsl:value-of select="lc:Title"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribute name="SRC">
<xsl:value-of select="lc:Image"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:value-of select="lc:Description"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>


我不知道你怎么样使用转换的结果。必须有一些显示转换结果的代码 - 例如分配

到innerHTML一些html objext的财产。

=====

欢呼,

Dimitre Novatchev。
http://fxsl.sourceforge.net/ - FXSL的主页


" Mark Constant" <共******* @ mix-net.net>在消息中写道

news:ce ************************** @ posting.google.c om ...
I don''t see how you use the result from the transformation. There must be
some code that displays the result of the transformation -- e.g. assignment
to the "innerHTML" property of some html objext.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mix-net.net> wrote in message
news:ce**************************@posting.google.c om...
我现在有一个下拉列表,当我从下拉列表中选择某些内容时,我得到了它,它调用了一个JavaScript函数。我希望它如此
从下拉列表中选择的值作为参数发送到xslt文件。当我从下拉列表中选择一个值时,不会出现
。我想要一个标题,图像和描述的基本列表
outputed。我已经完成了一个使用.write()
函数的基本JavaScript,并且该函数可以从下拉列表中将值发送到
JavaScript函数。所以问题必须是.addParameter函数。我可以缺少什么?

这是我的javascript和下拉菜单。
< body MS_POSITIONING =" FlowLayout">
< form id =" Form1中"方法= QUOT;交" runat =" server">
< SELECT name =" select1" onchange =''CallXML(this.form.select1);''>
< OPTION value =" Ratchet and Clank"> Ratchet and Clank< / OPTION>
< OPTION value = Sly Cooper> Sly Cooper< / OPTION>
< / SELECT>
< / form>
< / body>


< script language =" javascript">
函数CallXML(下拉列表)
{var myindex = dropdown.selectedIndex;
var SelValue = dropdown.options [myindex ] .value;
xml = new ActiveXObject(" Msxml2.DOMDocument.4.0");
xml.async = false;
xml.load(" Games.xml");
xslt = new ActiveXObject(" Msxml2.FreeThreadedDOMDocument.4.0");
xslt.async = false;
xslt.load(" Games.xslt");
xslTemp = new ActiveXObject(" Msxml2.XSLTemplate.4.0");
xslTemp.stylesheet = xslt;
var xslProc = xslTemp.createProcessor();
xslProc.input = xml;
xslProc.addParameter(Title,SelValue);
xslProc .transform;
xslProc.output;
}
< / script>

这是我的xslt文件。
<?xml version =" ; 1.0" encoding =" ISO-8859-1"?>
< xsl:stylesheet version =" 1.0"
xmlns:xsl =" http://www.w3.org/1999 / XSL / Transform"
xmlns:lc =" http:// mark / DevelopmentWebsite">
< xsl:output method =" html" />
< xsl :param name =" Title" />
< xsl:template match =" /">

< h2>我的游戏合集< / h2>
< table border =" 1">
< xsl:for-each select =" lc:Entertainment / lc:GameList [lc:Title =
I have a drop-down list now and I got it so when something is selected
from the drop down list it calls a JavaScript function. I want it so
the value selected from the drop-down list is sent as a parameter to
the xslt file. When I select a value from the drop-down list nothing
appears. I want just a basic listing of Title, Image, and Description
outputed. I have done a basic JavaScript that uses the .write()
function and that worked so the value is getting sent to the
JavaScript function from the drop-down list. So the problem has to be
with the .addParameter function. What could I be missing?

Here is my javascript and drop-down menu.
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<SELECT name="select1" onchange=''CallXML(this.form.select1);''>
<OPTION value="Ratchet and Clank">Ratchet and Clank</OPTION>
<OPTION value="Sly Cooper">Sly Cooper</OPTION>
</SELECT>
</form>
</body>


<script language="javascript">
function CallXML(dropdown)
{
var myindex = dropdown.selectedIndex;
var SelValue = dropdown.options[myindex].value;
xml = new ActiveXObject("Msxml2.DOMDocument.4.0");
xml.async = false;
xml.load("Games.xml");
xslt = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0" );
xslt.async = false;
xslt.load("Games.xslt");
xslTemp = new ActiveXObject("Msxml2.XSLTemplate.4.0");
xslTemp.stylesheet = xslt;
var xslProc = xslTemp.createProcessor();
xslProc.input = xml;
xslProc.addParameter(Title, SelValue);
xslProc.transform;
xslProc.output;
}
</script>

Here is my xslt file.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lc="http://mark/DevelopmentWebsite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Entertainment/lc:GameList[lc:Title =


Title]">
< tr>
< th colspan =" 2">< xsl:value-of select =" lc:Title" / >< / th>
< / tr>
< tr>
< td>
< xsl:element name =" IMG">
< xsl:attribute name =" SRC">
< xsl:value-of select =" lc:Image" />
< / xsl:attribute> < b r />< / xsl:element>
< / td>
< td>< xsl:value-of select =" lc:Description" />< / td>
< / tr>
< / xsl:for-each>
< / table>

< / xsl:template>
< / xsl:stylesheet>
Title]">
<tr>
<th colspan="2"><xsl:value-of select="lc:Title"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribute name="SRC">
<xsl:value-of select="lc:Image"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:value-of select="lc:Description"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>



这篇关于使用.addParameter()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆