2014-02-11 84 views
0

即时通讯工作的形式和即时通讯思想制作一个单选按钮,以便如果选择了no,输入行将被禁用或隐藏或什么。因此,当它被分析到下一页时,隐藏的值不再与其他值一起解析。我如何去做呢?例如具有考试和咨询价值的行。当我选择一个值为“否”的单选按钮时,如何使它不会向下一页发送任何值?如何隐藏输入值或禁止解析到表格上选择

形式

<script type="text/javascript"> 

var count = 0; 

function addTextArea(){ 
count= count+1; 
var div = document.getElementById('name'); 
div.innerHTML += "<div> <input type='text' name='name[]' value='' "+"id=name"+count+"> </div>"; 
//div.innerHTML += "\n<br />"; 
var div = document.getElementById('quantity'); 
div.innerHTML += "<div><input type='text' name='quantity[]' value ='' "+"id=quantity"+count+"></div>"; 
//div.innerHTML += "\n<br />"; 
var div = document.getElementById('amount'); 
div.innerHTML += "<div><input type='text' name='amount[]' value ='' "+"id=amount"+count+"></div>"; 
//div.innerHTML += "\n<br />"; 
} 

function removeTextArea(){ 
document.getElementById("name"+count).remove(); 

document.getElementById("quantity"+count).remove(); 

document.getElementById("amount"+count).remove(); 

count = count-1; 
} 

</script> 


</head> 

<body> 

<form method="POST" action="confirm_invoice.php" > 
<?php 
echo "<table border='2'>\n"; 
echo "<tr>\n"; 
echo "<th>Description</th>\n"; 
echo "<th>Quantity</th>\n"; 
echo "<th>Amount($)</th>\n"; 
echo "</tr>"; 

echo "<tr>"; 
echo "<td>"?><input type='text' size="50" name='name[]' value='Examination and Consultation' readonly/><?php "</td>"; 
echo "<td>"?><input type='text' size="50" name='quantity[]' value='' /><?php "</td>"; 
echo "<td>"?><input type='text' size="50" name='amount[]' value='' /><?php "</td>"; 
echo "</tr>"; 

echo "<tr>"; 
echo "<td>"?><input type='text' size="50" name='name[]' value='Anesthesia' readonly/><?php "</td>"; 
echo "<td>"?><input type='text' size="50" name='quantity[]' value='' /><?php "</td>"; 
echo "<td>"?><input type='text' size="50" name='amount[]' value='' /><?php "</td>"; 
echo "</tr>"; 

echo "<tr>"; 
echo "<td>"?><div id="name"></div> <?php "</td>"; 
echo "<td>"?><div id="quantity"></div> <?php "</td>"; 
echo "<td>"?><div id="amount"></div> <?php "</td>"; 
echo "</tr>"; 
?> 
<br /> 
<input type="button" value="Add Description" onClick="addTextArea();"> &nbsp; 
<input type="submit" name="submit" value="submit"> 

<input type="button" value="Remove Description" onClick="removeTextArea();"> &nbsp; 
<input type="submit" name="submit" value="submit"> 

</form> 

</body> 
</html> 

回答

0

你应该给禁用=“禁用”,以输入的属性,以防止它被发送到与表单后的下一个页面。

使用JS这样的功能:

function disableInputs(cnt) 
{ 
    document.getElementById("name"+cnt).disabled = "disabled"; 
    document.getElementById("quantity"+cnt).disabled = "disabled"; 
    document.getElementById("amount"+cnt).disabled = "disabled"; 
} 

和电台应该是这样的:

<input type="radio" name="disableInput" value="1" onclick="javascript:disableInputs(1)"> 

所以在你的JS函数,你可以这样添加:

function addTextArea(){ 
count= count+1; 
var div = document.getElementById('name'); 
div.innerHTML += "<div> <input type='text' name='name[]' value='' "+"id=name"+count+"> </div>"; 
var div = document.getElementById('quantity'); 
div.innerHTML += "<div><input type='text' name='quantity[]' value ='' "+"id=quantity"+count+"></div>"; 
var div = document.getElementById('amount'); 
div.innerHTML += "<div><input type='text' name='amount[]' value ='' "+"id=amount"+count+"></div>"; 
div.innerHTML += "<div><input type='radio' name='disableInput' value='1' onclick='javascript:disableInputs(" + count + ")'></div>"; 
}