所以我一直在尝试编写组合多行 html 的函数,所以当我调用 JS 函数时,该 html 会放在我的网页上。这是我开始工作的一个例子:
function buildproduct(prodName, prodID, prodDescription) {
var data = makeHeader()
data += "<TABLE style='width:100%' border=1 cellpadding=10>"
data += "<TR><TD rowspan=3 style='width:30%;text-align:center;vertical-"
data += "align:middle'>" + makeImage(prodID) + ""
data += "</TD>"
data += "<TD>" + makeName(prodName) + "</TD>"
data += "<TD style='text-align:right'>" + makeID(prodID) + "</TD>"
data += "</TR>"
data +="<TR><TD style='text-align:center' colspan=2>" + makeLinkbar(prodID) + ""
data += "</TD></TR>"
data += "<TR><TD colspan=2 >" + makeDescription(prodDescription) + ""
data += "</TD></TR>"
data += "</TABLE>"
data += makeFooter()
productarea.document.writeln(data)
productarea.document.close()
}
上面的代码我已经开始工作了。这是我似乎无法正常工作的代码:
function makeLinkbar(prodID) {
var data = "<form name="_xclick" target="paypal" action=https://www.paypal.com method="post">"
data += "<input type="hidden" name="cmd" value="_cart">"
data += "<input type="hidden" name="business" value="nora-alice@paypal.com">"
data += "<input type="hidden" name="item_name" value="HTML book">"
data += "<input type="hidden" name="amount" value="24.99">"
data += "<input type="hidden" name="item_number" value="12345">"
data += "<input type="image" src=http://www.paypal.com/en_US/i/btn/sc-but-01.gif border="0" name="submit"alt="Make payments with PayPal - it's fast, free and secure!">"
data += "<input type="hidden" name="add" value="1">"
data += "</form>"
return(data)
}
任何想法为什么我不能让这个函数正确输出 html?事实上,它根本不起作用。多谢你们!