0

我有一个嵌入代码,当我单击计算按钮时会显示该代码

<script type="text/javascript">
function ln(){
document.getElementById('looknorth').innerHTML='<embed bgcolor="#dbdbd3" flashvars="lcId=1169793726234&amp;state=symbol%3D%5Ensebank;range=1d;indicator=ema(13,34,55)+macd+rsi+stochasticfast;charttype=candlestick;crosshair=on;ohlcvalues=0;logscale=on;source=undefined" loop="false" menu="false" name="BANKNIFTY" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://us.js2.yimg.com/us.yimg.com/i/us/fi/yfc/swf/flashchart_1.18.swf" style="height: 775px; width: 550px" type="application/x-shockwave-flash" wmode="opaque"></embed>';
  }     
</script>
<input type=button style="background-color:#123742; color:#FFFFFF ; font-weight:bold; font-size:15" name=Button2 value=Calculate onClick=ln();></td></tr>

我想要一个下拉菜单,它采用符号“symbol%3D%5Ensebank;”的值 从下拉菜单的值。

我添加了代码

<select size="1" name="D1">
<option value="nsei" selected>Nifty</option>
<option value="bsen">Sensex</option>
</select><input type="submit" value="Submit" name="B1" onClick=ln();></p>

但是要在嵌入代码中进行哪些更改以从 D1 获取符号值

请帮忙

<div id="looknorth"></div>
<script type="text/javascript">
function ln(vidvar){

tempcell = document.createElement("embed");
tempcell.setAttribute("bgcolor","#dbdbd3");
tempcell.setAttribute("flashvars",
("lcId=1169793726234&amp;state=symbol="
+vidvar+
";range=1d;indicator=ema(13,34,55)+macd+rsi+stochasticfast;charttype=candlestick;crosshair=on;ohlcvalues=0;logscale=on;source=undefined")
);
tempcell.setAttribute("loop","false");
tempcell.setAttribute("menu","false");
tempcell.setAttribute("name","Bank Nifty");
tempcell.setAttribute("pluginspage","http://www.macromedia.com/go/getflashplayer");
tempcell.setAttribute("src","http://us.js2.yimg.com/us.yimg.com/i/us/fi/yfc/swf/flashchart_1.18.swf");
tempcell.setAttribute("style","height: 775px; width: 550px");
tempcell.setAttribute("type","application/x-shockwave-flash");
tempcell.setAttribute("wmode","opaque");


document.getElementById('looknorth').innerHTML=""
document.getElementById('looknorth').appendChild(tempcell);

}

<form name="Video" id="search" onsubmit="ln(search.D1.value)">

<select size="1" name="D1">
<option value="^nsei" selected>Nifty</option>
<option value="^bsesn" >Sensex</option>
</select>

<input type="submit" value="Submit" name="B1" onClick=ln();>

我试图调试代码,但仍然无法正常工作。请帮忙

4

1 回答 1

0

您需要将它们包含在表单标签中。

<form name="Video" id="search" onsubmit="ln(search.D1.value)">

<select size="1" name="D1">
<option value="nsei" selected>Nifty</option>
<option value="bsen" >Sensex</option>
</select>

<input type="submit" value="Submit" name="B1" />

</Form>

然后,改变 ln() 让它接受一个变量,所以也许试试:

<script type="text/javascript">
function ln(vidvar){

tempcell = document.createElement("embed");
tempcell.setAttribute("bgcolor","#dbdbd3");
tempcell.setAttribute("flashvars",
    ("lcId=1169793726234&amp;state="
    +vidvar+
    ";range=1d;indicator=ema(13,34,55)+macd+rsi+stochasticfast;charttype=candlestick;crosshair=on;ohlcvalues=0;logscale=on;source=undefined")
    );
<!-- And  so on for the rest of the attributes of the <embed> tag -->   
document.getElementById('looknorth').innerHTML=""
document.getElementById('looknorth').appendChild(tempcell);
  }     
</script>

这可能有一些错误,但这是一般的想法。

于 2012-05-25T17:58:28.577 回答