弹出确认框选择更改

时间:2018-05-22 15:10:39

标签: javascript html

我有SELECT字段的HTML表单,当我选择选项时,我想启动CONFIRM消息,如果我选择"是"它应该提交表格。

我该怎么做?

<form action="index.php?page=<?PHP echo $_GET['page'] ?>" method="post" >

    <select name="planID" onChange="this.form.submit()" class="form-control">
            <option value="">Choose plan1</option>
            <option value="">Choose plan2</option>
            <option value="">Choose plan3</option>
    </select>
</form>

1 个答案:

答案 0 :(得分:0)

HTML:

<form action="index.php?page=<?PHP echo $_GET['page'] ?>" method="post" id="myForm">

    <select name="planID" onchange="if(confirm('Are you sure?')) document.getElementById('myForm').submit();" class="form-control">
            <option value="">Choose plan1</option>
            <option value="">Choose plan2</option>
            <option value="">Choose plan3</option>
    </select>
</form>