如何更改select标记的onchange事件上的select标记的值。 HTML

时间:2012-11-01 10:49:59

标签: php javascript html

我需要检查select标签的值何时更改,如果它等于说“NA”,如果是这样,它需要将另一个select标签的值更改为不同的值并禁用它?

我正在使用php。如果有一种方式在PHP让我知道。请

<html>
<center>
<title>Testing</title>
<head>
<script>
function closeWin()
{
alert('Posted');
window.open('', '_self', '');
    window.close();
}
//Function to test value and change value
function value()
{
if (Question4DDL == 'NA')
{
Question5DDL == 'NA'
}
{


}
</script>
</head>
<form name="input" action="index.php" method="post" >

<body>
<div id="Questions">
<table>
<tr><td>
<div id="Q1">Subscribed to service provider?</div>
</td>
<td>
<select Name="Question1DDL">
   <option value = 'BLANK'></option> 
<option value = 'YES'>YES</option>
    <option value ='NO'>NO</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q2">Which provider are you currently with?</div>
</td>
<td>
<select Name="Question2DDL">
<option value = 'BLANK'></option> 
    <option>t1</option>
    <option>t2</option>
    <option>t3</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q3">Type of dwelling/premisis?</div>
</td>
<td>
<select Name="Question3DDL">
<option value = 'BLANK'></option> 
    <option>CLUSTER</option>
    <option>FLAT</option>
    <option>PLOT</option>
    <option>TOWNHOUSE</option>
    <option>FARM</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q4">Alarm in working order?</div>
</td>
<td>

//select tag in question.
<select Name="Question4DDL" onchange="value()">
<option value = 'BLANK'></option> 
    <option>YES</option>
    <option>NO</option>
    <option value = 'NA'>(N/A) - No Alarm</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q5">Age of alarm?</div>
</td>
<td>
<select Name="Question5DDL">
<option value = 'BLANK'></option> 
    <option>-1</option>
    <option>-3</option>
    <option>+3</option>
</select>

</td>
</tr>
<tr>
<td>
<div id="Q6">Paying more than R350 per month?</div>
</td>
<td>
<select Name="Question6DDL"><option value = 'BLANK'></option> 
    <option>YES</option>
    <option>NO</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q7">Is the prospect in a known response area? (Have they seen sign boards in their area?)</div>
</td>
<td>
<select Name="Question7DDL">
<option value = 'BLANK'></option> 
    <option>YES</option>
    <option>NO</option>
</select>
</td>
</tr>
<tr>
<td>
<div id="Q8">Request site visit from agent?</div>
</td>
<td>
<select Name="Question8DDL">
<option value = 'BLANK'></option> 
    <option>YES</option>
    <option>NO</option>
</select>
</td>
</tr>
<tr>
<td>
</td>
<td>
<textarea name="comments"  rows="5">
</textarea>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input name="sb1" type="submit" value="Submit" onClick="closeWin()">
</td>
</tr>

</table>
</div>
</body>
</form>
</center>
</html>

1 个答案:

答案 0 :(得分:1)

首先获得用户选择的用户输入 在使用该输入后,您将使用if条件,如果服务提供者是,则执行if循环并显示您想要显示的其他选项,否则按照您将提供的进一步程序。 我不知道PHP所以在这里我给出描述,否则我会创建首先获得用户输入的代码,然后继续。