<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Insert title here</title>
</head>
<body>
<table>
<tr>
<td>
<input type="checkbox" name="checkbox1"/>white
<input type="checkbox" name="checkbox2"/>black
<input type="checkbox" name="checkbox3"/>red
<input type="checkbox" name="checkbox4"/>yellow
</td>
</tr>
<tr>
<td>
ColorName:<input type="text" name="color"/>
<input type="button" name="addCheckbox" value="addCheckbox"/>
</td>
</tr>
</table>
</body>
</html>

解决方案 »

  1.   

    这是个表单:里面有四个文本框,和一个Button按钮。很简单的表单提交数据问题
      

  2.   

    text 里写 colorName 按添加按钮 就能增加上面的 checkbox的数量
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN " "http://www.w3.org/TR/html4/loose.dtd "> 
    <html> 
    <head> 
    <title> Insert title here </title> 
    </head> 
    <body> 
    <table> 
    <tr> 
    <td id="checkColor"> 
    <input type= "checkbox" name= "checkbox1 "/> white 
    <input type= "checkbox" name= "checkbox2 "/> black 
    <input type= "checkbox" name= "checkbox3 "/> red 
    <input type= "checkbox" name= "checkbox4 "/> yellow
    </td> 
    </tr> 
    <tr> 
    <td> 
    ColorName: <input type="text" name= "color " id="color"/> 
    <input type= "button" name= "addCheckbox " value= "addCheckbox" onclick="addColor();"/> 
    <script type="text/javascript">
    var addColor = function(){
    var txtColor = document.getElementById("color");
    if(!isEmpty(txtColor)){return;}
    var td = document.getElementById("checkColor");
    var ch = "<input type='checkbox' name='checkbox" + td.getElementsByTagName("input").length + "' /> " + txtColor.value;
    td.innerHTML += ch;
    } function isEmpty(txt){
            var value = txt.value.replace(/(^\s*)|(\s*$)/g, "");
            if(value.length == 0){
                alert("请填写颜色名称!");
    txt.focus();
    return false;
            }
    return true;
        }
    </script>
    </td> 
    </tr> 
    </table> 
    </body> 
    </html>