<script>
var gid='{Field="Surveyname"/}';
var xid='{Field="Surveyid"/}';
gid=gid.split("err:无记录");
if(gid.length>1){
}
else{
document.write('<Iframe src="/Common/Vote.aspx?sid=4" width="220" height="170" scrolling="no" frameborder="0"></iframe>');
}
</script>以上是在CMS中调用字段,把这个字段做为参数传给下面的语句。
希望将sid=4中的4这个ID更换为XiD这个已赋值的参数,自己试了半天不行,个人的JS水平有限,请大家帮助一下。
试过:document.write('<Iframe src="/Common/Vote.aspx?sid={Field="Surveyid"/}" width="220" height="170" scrolling="no" frameborder="0"></iframe>');不行呢
如何做,很急

解决方案 »

  1.   

    function init(){
    var a="测试";
        document.write('<Iframe src="http://www.baidu.com/s?word=a" width="220" height="170" scrolling="no" frameborder="0" id="test"></iframe>');
    document.getElementById("test").setAttribute("src","http://www.baidu.com/s?word="+a);
    }
    window.onload=init;
    不明白你的意思
      

  2.   

    document.write('<Iframe src="/Common/Vote.aspx?sid='+xid+'" width="220" height="170" scrolling="no" frameborder="0"></iframe>');
      

  3.   

    document.write('<Iframe src="/Common/Vote.aspx?sid="'+xid+' width="220" height="170" scrolling="no" frameborder="0"></iframe>');
      

  4.   

    document.write('<Iframe src="/Common/Vote.aspx?sid="+xid width="220" height="170" scrolling="no" frameborder="0"></iframe>');
      

  5.   

    各位老师,还是不行啊,最关键的是以下代码。
    document.write('<Iframe src="/Common/Vote.aspx?sid=4" width="220" height="170" scrolling="no" frameborder="0"></iframe>');
    可以
    document.write('<Iframe src="/Common/Vote.aspx?sid={Field="Surveyid"/}" width="220" height="170" scrolling="no" frameborder="0"></iframe>');
    就不行,用大家的方法也都出不来,再一次请教。
    用先把{Field="Surveyid"/}做为变量赋值吗?进行字符串相加是不是我的语法不对
      

  6.   

    各位老师,以上的改动还是不行呢,
    var xid={Field="Surveyid"/};
    document.write('<Iframe src="/Common/Vote.aspx?sid='+xid+'" width="220" height="170" scrolling="no" frameborder="0"></iframe>');
    为什么不行呢,是不是字段串的连接还是有问题,本人JS菜鸟