选项选择Javascript值

时间:2015-09-07 02:14:58

标签: javascript forms select html-table

无法选择选项值,因为该值来自Javascript

例如:

           <td>Nationality
            <select id="nationality" name ="nationality" >
            <option selected="true" value="Malaysia"> Malaysia </option>
            </select>
            <script language="javascript">
            nationality("nationality");
            </script>
            </td>
            </tr>

我如何保持马来西亚的价值,因为我刷新后会返回&#34;请选择&#34; ...

1 个答案:

答案 0 :(得分:0)

将选中的选项置于选项标签中以默认选择值。

<td>Nationality
        <select id="nationality" name ="nationality" >
        <option selected="true" value="Malaysia" selected> Malaysia </option>
        </select>
        <script language="javascript">
        nationality("nationality");
        </script>
        </td>
        </tr> 

我希望这有效。