当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - src value in iframe not change at runtime

问题描述:

In my application I want to change the src value of iframe on click of radio button But when I try to do that I got error as:

ReferenceError: Left side of assignment is not a reference

Here is my html code as:

<div data-role="fieldcontain">

<fieldset data-role="controlgroup" data-type="horizontal">

<input id="aaa" name="exch_type" type="radio" value="AAA" checked="checked"/>

<label for="aaa" style="width: 125px;">AAA</label>

<input id="bbb" name="exch_type" type="radio" value="BBB" />

<label for="bbb" style="width: 125px;">BBB</label>

</fieldset>

</div>

</div>

<div align="center">

<iframe name = "chartId" id = "chartId" src="http://myDomain/chts/mobile.asp?Scrip=AAA&Exchange=XXX&ChartType=I&Hg=150&Wd=300" scrolling="yes"></iframe>

</div>

And click function as

$('input[name=exch_type]').change(function()

{

var radio_val = $('input[name=exch_type]:checked').val();

if (radio_val=="AAA")

{

$("#chartId").attr("src") = "http://myDomain/charts/mobilechart.asp?Scrip=AAAIND&Exchange=NSE&ChartType=I&Hg=150&Wd=300";

}

else if (radio_val=="BBB")

{

$("#chartId").attr("src") = "http://myDomain/charts/mobilechart.asp?Scrip=BBBIND&Exchange=NSE&ChartType=I&Hg=150&Wd=300";

}

//alert('Radio Value: '+radio_val);

});

Any help will be appreciated Thanks in advance

网友答案:

I've not tested but, note a bad assignment:

$("#chartId").attr("src") = src="http://myDomain/chts/mobile.asp?Scrip=AAA&Exchange=XXX&ChartType=I&Hg=150&Wd=300";

instead of:

$("#chartId").attr("src", "http://myDomain/chts/mobile.asp?Scrip=AAA&Exchange=XXX&ChartType=I&Hg=150&Wd=300");
网友答案:

try this:

$("#chartId").attr("src", "http://myDomain/chts/mobile.asp?Scrip=AAA&Exchange=XXX&ChartType=I&Hg=150&Wd=300");
分享给朋友:
您可能感兴趣的文章:
随机阅读: