0

我正在构建一个包含多个字段的表单,并将其放置在表格中以便于阅读。我想在表单内有一个下拉菜单,但是使用“选择/选项”标签,我总是在整个表单之前或之后都有下拉菜单。我能怎么做?这里有一个例子:

    document.write('name "Addrow" <form action="xxxxxx.php?Mode=ADD" method="POST" enctype="multipart/form-data">')
    document.write('<table width="900"><th width="250"></th><th width="650"></th>')
    document.write('<TR>')
    document.write('<TD>Codice evento:</td>')
    document.write('<TD><input type="text" name="ID_evcls" maxlength="10" size="10"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TD>Tipo evento:</td>')
    document.write('<TD><input type="text" name="ID_tipoev" maxlength="5" size="10"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TR>')
    document.write('<TD>Titolo:</td>')
    document.write('<TD><input type="text" name="TitEv" maxlength="35" size="35"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TR>')
    document.write('<TD>Descrizione:</td>')
    document.write('<TD><input type="text" name="Descr" maxlength="150" size="75"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TR>')
    document.write('<TD>Data manifestazione:</td>')
    document.write('<TD><input type="date" name="DataEv"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TR>')
    document.write('<TD>Luogo manifestazione:</td>')
    document.write('<TD><input type="text" name="PlacEv" maxlength="25" size="25"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TR>')
    document.write('<TD>Nazione:</td>')
    document.write('<TD><input type="text" name="NatEv" maxlength="3" size="3" value="ITA"></td>')
    document.write('</TR>')
    document.write('<TR>')
    document.write('<TD>Immagine da utilizzare (JPEG):</td>')
    document.write('<TD><input type="file" name="userfile"accept="image/jpeg"></td>')
    document.write('</TR>')
    document.write('</table>')
    fn_buildchooseeventclass()
    document.write('<input type="submit" value="Conferma inserimento">')
    document.write('</form>')
}

function fn_buildchooseeventclass() {
    document.write('<select name="carlist" form="Addrow">')
    document.write('<option value="volvo">Volvo</option>')
    document.write('<option value="saab">Saab</option>')
    document.write('<option value="opel">Opel</option>')
    document.write('<option value="audi">Audi</option>')
    document.write('</select>')
}


</script>

</body>
</html>
4

1 回答 1

1

您必须将其插入<tr><td>

所以,如果我按照你的风格去做:

document.write('<TR>');
document.write('<TD>');
fn_buildchooseeventclass();
document.write('</TD>');
document.write('</TR>');
document.write('</table>');

编辑:这里是工作示例:http: //jsbin.com/axuxiz/1/edit

<table>一些旁注:使用 a来布局四页被认为是一种不好的布拉德做法。用来document.write创建你的用户界面是相当低效的。

于 2013-03-25T14:38:29.713 回答