复选框onclick事件加载,就像检查一样

时间:2011-08-30 21:44:48

标签: javascript html

当我加载页面时,会显示两个表单。如果我检查然后取消选中“添加”,则第二个表单将消失。如何在加载时隐藏表单2来加载此页面?

<html>
<title>Car Service</title>
<strong>Car Service:</strong><br><br>
<input type="submit" id="accountsearch" name="accountsearch" value="Select Customer" onclick="window.open('selectaccount.php');"><br><br>
<form name="newservicesetup" id="newservicesetup" action="" method="post">
    <select name="ordertype" id="ordertype">
        <option>(Select Service)</option>
        <option value="Service">Service</option>
        <option value="ServiceHardware">Service w/ Hardware</option>            
    </select>
    <input type="text" name="qty1" id="qty1" value="Quantity" size="5" onclick="this.value=''">
    <input type="checkbox" id="add" value="0" name="add" onclick="
        if (this.checked) {
            document.getElementById('newservicesetup1').style.display='inline';
        } else {
            document.getElementById('newservicesetup1').style.display='none'; } return true;" >
</form>
<form name="newservicesetup1" id="newservicesetup1" action="" method="post">
    <select name="ordertype1" id="ordertype1">
        <option>(Select Service)</option>
        <option value="Service">Service</option>
        <option value="ServiceHardware">Service w/ Hardware</option>            
    </select>
    <input type="text" name="qty2" id="qty2" value="Quantity" size="5" onclick="this.value=''">
</form>
<br>
    XX: <input type="file" name="sfa" id="sfa">
    AA1: <input type="file" name="pbxws" id="pbxws"><br>    <br>
    <input type="submit" name="next" id="next" value="Next">       

2 个答案:

答案 0 :(得分:1)

将第二个表单css类设置为隐藏或类似的东西然后在你的css中定义.hidden为display:none。或者在第二个表单

上放置style ='display:none't ostart

答案 1 :(得分:0)

更改您的第二个表单标签以阅读此内容....

<form name="newservicesetup1" id="newservicesetup1" action="" method="post" style="display:none;">