为什么选择保留重载后先前选择的值

时间:2015-03-06 20:27:43

标签: javascript html browser

我有一个后续页面,我在下拉列表中设置默认选定项目。我从选择下拉列表中选择一个新值。页面刷新后选择了该值但未选择默认值。我正在使用Mozilla Firefox。这在chrome中没有发生。在Firefox(版本-35.0.1)中出现此行为的原因是什么。 我需要知道为什么在chrome和firefox中发生了不同的事情。

<html>
<head>


<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>

<link rel="stylesheet" type="text/css" href="style.css">

</head>
<body>
<div class="container">

<form name="" action="auth.php" method ="post">
<div>
 <table id="one-column-emphasis">  
<tr>
<th>
Student Name:</th>
<td><input type="text" name="student_name" required>
</td>
</tr>
<tr>
<th>Mobile No/Email </th>
<td><input type="text" name="mobile" required>
</td>
</tr>
<tr>
<th>Examination:</th>
<td><select name="exam"id="exam"onchange="myFunction()" required>
                          <option value="hs"selected>HS</option>
                          <option value="cbse">CBSE</option>
                          <option value="icse">ICSE</option>
                          <option value="other">OTHER</option>
            </select>
        </td>
        <td><input type="hidden" name="other_exam" id="other_exam"></td>
    </tr>
<tr>
<th>Board:</th>
<td><select name="board" onchange="myFunction1()"id="board"required>
                          <option value="WBCHSE" selected>W.B.C.H.S.E</option>
                          <option value="cbse">C.B.S.E</option>
                          <option value="icse">I.C.S.E</option>
                          <option value="other">OTHER</option>
            </select>
        </td><td><input type="hidden" name="other_board" id="other_board"></td>
    </tr>
<tr>
<th>Roll No</th>
<td><input type="text" name="roll"required>
</td>
</tr>
<tr>
<th>Year of Passing</th>
                        <td><select name="yop"required>
                             <option value="2013"selected>2013</option>
                             <option value="2014">2014</option>
                             <option value="2015">2015</option>
                             </select>
                         </td>
</tr>
<tr>
    <td >
<input type="reset" name="submit" value="Reset">
    </td>
    <td>

<input type="submit" name="submit" value="Next">
    </td>
</tr>
</table>
</form>
</div>
<script>
function myFunction() {
    var x = document.getElementById("exam").value;
    if(x=="other")
document.getElementById("other_exam").type = "text";
   else
document.getElementById("other_exam").type = "hidden";
}
function myFunction1() {
    var x = document.getElementById("board").value;
    if(x=="other")
document.getElementById("other_board").type = "text";
else
document.getElementById("other_board").type = "hidden";
}

</script>



</body>
</html>

0 个答案:

没有答案