value值要从外部变量中获取,类似于XXXX.value=name;这样。我试了好多种文本框中都只显示字符串,比如上边那句就显示name,而不显示name的具体值。。贴上关键代码,求大神解惑!
var content = "<br>" +
"位置:" + X + "," + Y + "<br>" +
"名称:" + '<input type="text" id="txt1" value="789" />' + "<br>" +
"范围:" + '<input type="text" id="txt2" value="&name" />' + "<br>" +
"类型:" + '<input type="text" id="txt3" value=&name />' + "<br>" +
"状态:" + '<input type="text" id="txt4" value="+name+" />' + "<br>" +
"备注:" + '<input type="text" id="txt5" value="" />' + "<br>" + "<br>" +
'<input type="button" onclick="" value="查看" />' + " " +
'<input type="button" onclick="set();" value="提交" />';
上面的几个value显示在文本框中都是字符,有没引号都一样

解决方案 »

  1.   

    我目前是把赋值语句写在打开信息窗口的函数中,打开操作的后面,如下面代码。问题是第一次打开信息窗口后text里边不显示数据,关掉再次打开就会显示了。怎样实现第一次打开就能读取到数据?我尝试放在打开窗口操作上面出错了。。请教各位大神!
    function openInfo(content, e)
                {
                    var p = e.target;
                    var point = new BMap.Point(p.getPosition().lng, p.getPosition().lat);
                    var infoWindow = new BMap.InfoWindow(content, opts);
                    map.openInfoWindow(infoWindow, point);
                    document.getElementById("txt1").value = name;
                    document.getElementById("txt2").value = num;
                    document.getElementById("txt3").value = type;
                    document.getElementById("txt4").value = status;
                    document.getElementById("txt5").value = re;
                }
      

  2.   

    我也遇到了同样的问题,在自定义窗体中有表单控件如 input控件,
    1:使用document.getElementById('title').value ="title";
    2:然后将这个加载到var infoWindow = new BMap.InfoWindow(content);
    3: map.openInfoWindow(infoWindow, point);
    问题,infoWindow中的input控件腹部上值