在div中使用select选项

时间:2015-11-08 18:27:54

标签: jsp netbeans

我正在使用Netbeans Java Web Applications,所以我有这样的结构:

  <div class="col-md-4">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4><i class="fa fa-fw fa-check"></i>Low Service </h4>
                </div>
                <div class="panel-body">
                    <p>This is low service</p>
                    <a href="#" class="btn btn-default">Select</a>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4><i class="fa fa-fw fa-gift"></i> High Service</h4>
                </div>
                <div class="panel-body">
                    <p>This is high service</p>
                    <a href="#" class="btn btn-default">Select</a>
                </div>
            </div>

我在这里选择:

  <form method="POST" action="Servlet" >

    <select name="service">
        <option value="">Select an option</option>
        <option value="Low service" name="sme"></option>
        <option value="High service" name="sma"></option>
 </select>
 </form>

所以我想要的是当用户clic on我的结构上的“选择”按钮时,它得到了form form post的动作,最后隐藏了正常的select标签。我怎么能这样做?

例如我试试这个:

<form method="POST" action="Servlet" >

    <select name="service" onchange="this.form.submit()">

  <div class="col-md-4">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4><i class="fa fa-fw fa-check"></i>Low Service </h4>
                </div>
                <div class="panel-body">
                    <p>This is low service</p>
                    <option value="Low service" name="sme">Select</option>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4><i class="fa fa-fw fa-gift"></i> High Service</h4>
                </div>
                <div class="panel-body">
                    <p>This is high service</p>
                    <option value="High service" name="sma"></option>
                </div>
            </div>

     

但它只会将我的css转换为选择选项......

1 个答案:

答案 0 :(得分:0)

要根据用户选择提交表单,您应该使用以下内容:

<select name="service" onchange="this.form.submit()">
    ...
</select>