如何在JSP文件中创建禁用参数?

时间:2016-06-29 06:07:20

标签: json jsp javabeans

如何创建一个禁用参数来保存员工ID并将带有表单数据的参数传递给servlet并更改数据库?

任何有关获取已禁用的employeeID值的建议都表示赞赏。

<form class="form-horizontal" id="form_editemp">
        <fieldset>

            <!-- Form Name -->
            <legend>Edit Employee Information</legend>

            <!-- Text input-->
             <div class="form-group">
             <label id="empid" class="col-md-4 control-label" for="empid"    >Employee ID:</label>
             <div class="col-md-4">
                <input id="empid" name="empid" type="text"
                          class="form-control input-sm"
                          value = "${emp.empid}" disabled> <span   class="help-block"> </span>
                </div>
            </div>

            <!-- Text input-->
            <div class="form-group">
                <label class="col-md-4 control-label" for="empName">Employee   Name:</label>
                <div class="col-md-4">
                    <input id="empName" name="empName" type="text"
                          class="form-control input-md"
                        required="" value = "${emp.empName}" > <span   class="help-block"> </span>
                </div>
            </div>

            <!-- Text input-->
            <div class="form-group">
                <label class="col-md-4 control-label" for="hireDate">Hire   Date:</label>
                <div class="col-md-4">
        <input id ="date" name="hireDate" type="text" class="form-control"   value = "${emp.hireDate}"><span class="input-group-addon"><i class="glyphicon   glyphicon-th"></i></span>
    </div>
            </div>  

            <!-- Button (Double) -->
            <div class="form-group">
                <label class="col-md-4 control-label" for="submitempedit">Submit</label>
                <div class="col-md-4">
                    <button id="submitempedit" name="submitempedit"   class="btn btn-primary">Submit</button>
                </div>
            </div>
            </fieldset>
    </form>

 <script>
 $('#date').datepicker({

    });
 </script>

 <script>
$('#submitempedit').click(function() {
//Open modal (popup) window
//Define variable for the form inside the modal
var $form = $("#form_editemp");
//Javascript object based on form calling the function below
var data = getFormData($form);
var empid = document.getElementById("empid").getAttribute("value");
console.log(x);
//Json string by converting javascript object above to json
var json = JSON.stringify(data);

1 个答案:

答案 0 :(得分:1)

将其显示为简单文本,并在表单中添加隐藏字段:

<input type="hidden" name="empid" value="${emp.empid}"/>