我正在尝试使用 JavaScript 构建以下 HTML:
<td> <a data-toggle="modal" class="btn" href="sales.asp?origen=NY&number=036529" data-target="#myModal">View Sale</a> </td>
我正在尝试使用以下代码构建它,但出现错误:
document.write("<td> <a data-toggle='modal' class='btn' href=.......
有谁知道该怎么做?
我的脚本就是这个,我想添加一个按钮来打开一个模式窗口,该窗口显示一个页面,该页面的参数取自“for”
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","xml/xml_compras.asp?origen=granada",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table class='table table-striped table-condensed table-bordered' id='example'>");
document.write("<thead>");
document.write("<tr class='odd gradeX'>");
document.write("<th>Albaran</th>");
document.write("<th>Proveedor</th>");
document.write("<th>F. Albaran</th>");
document.write("<th>F. Servicio</th>");
document.write("<th>Articulo</th>");
document.write("<th>Cantidad</th>");
document.write("<th class='hidden-phone'>Precio</th>");
document.write("<th class='hidden-phone'>Importe</th>");
document.write("<th>Alb. Venta</th>");
document.write("</tr>");
document.write(" </thead>");
var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>"); document.write(x[i].getElementsByTagName("numeroAlbaran")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("proveedor")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("fechaAlbaran")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("fechaServicio")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("articulo")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("cantidad")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td class='hidden-phone'>"); document.write(x[i].getElementsByTagName("precio")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td class='hidden-phone'>"); document.write(x[i].getElementsByTagName("importe")[0].childNodes[0].nodeValue); document.write("</td>");
document.write("<td>"); document.write(x[i].getElementsByTagName("albaranVenta")[0].childNodes[0].nodeValue); document.write("</td>");
var url = document.write(x[i].getElementsByTagName("importe")[0].childNodes[0].nodeValue);
//alert(url);
document.write("<td> <a data-toggle='modal' class='btn' href="'+url+'"> data-target='#myModal'>click me</a> </td>")
document.write("</tr>");
}
document.write("</table>");
</script>