Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 打开带有预填充字段的对话框(单击“编辑链接”后)_Javascript_Jquery_Css_Jsp_Servlets - Fatal编程技术网

Javascript 打开带有预填充字段的对话框(单击“编辑链接”后)

Javascript 打开带有预填充字段的对话框(单击“编辑链接”后),javascript,jquery,css,jsp,servlets,Javascript,Jquery,Css,Jsp,Servlets,(单击编辑链接后):java.lang.NumberFormatException:null作为错误出现 我想做的是填充单击编辑按钮后弹出的对话框。我使用了一个插件。演示:。我只想使用问题中描述的编辑部分。我没有使用脚本标记中的所有函数。我只想预填充字段:学生Id,对话框打开后的Firsname、lastname、yearlevel //Studentinfo.jsp <div class="CSSTableGenerator" > <div id="u

(单击编辑链接后)java.lang.NumberFormatException:null作为错误出现

我想做的是填充单击编辑按钮后弹出的对话框。我使用了一个插件。演示:。我只想使用问题中描述的编辑部分。我没有使用脚本标记中的所有函数。我只想预填充字段:学生Id,对话框打开后的Firsname、lastname、yearlevel

//Studentinfo.jsp

    <div class="CSSTableGenerator" >
        <div id="users-contain" class="ui-widget">
            <h1>Existing Users:</h1>
    <table id="users" class="ui-widget ui-widget-content" border="1">
        <thead>
            <tr class="ui-widget-header ">
                <th>Student ID</th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Year Level</th>
                <th>Actions</th>
               </tr>
        </thead>

        <tbody>

        <c:forEach items="${allStudents}" var="stud">
            <tr class="nr">
                <td>${stud.studentId}</td>
                <td>${stud.firstname}</td>
                <td>${stud.lastname}</td>
                <td>${stud.yearLevel}</td>
                <td><a class="edit" href="">Edit</a></td>

            </tr>
        </c:forEach>
        </tbody>
        </table>
        </div>
                <hr>
                <div id="dialog-form" title="Create new user">
                 <p class="validateTips">All form fields are required.</p>
            <form name="frm" action="./StudentServlet" method="POST" onSubmit="return validateForm()">
                <fieldset>
                <label for="student-ID">Student ID</label><input type="text" id="Student-ID"  class="text ui-widget-content ui-corner-all"  name="Student-ID" value="" />
                <label for="first-name">First Name</label><input type="text" id="first-name"  class="text ui-widget-content ui-corner-all"  name="first-name" value="" />
                <label for="last-name">Last Name</label><input type="text" id="last-name"  class="text ui-widget-content ui-corner-all"  name="last-name" value="" />
                <label for="yearLevel">year Level</label><input type="text" id="yearLevel"  class="text ui-widget-content ui-corner-all"  name="yearLevel" value="" />
                </fieldset>
            </form>
               </div>



  </div>

            </section>
     <br>
         <form name="frm" action="./StudentServlet" method="POST" >
            <tr>
                <td><strong>Student ID --></strong><input type="text" name="studentId" value="${student.studentId}" /> </td>
                <td><strong>First Name --></strong><input type="text" name="firstname" value="${student.firstname}" /> </td>
                <td><strong>Last Name --></strong> <input type="text" name="lastname" value="${student.lastname}" /> </td>
                <td><strong>Year Level --></strong><input type="text" name="yearLevel" value="${student.yearLevel}" /> </td>
            </tr>   

        <table>

我哪里做错了??plz帮助。

我选择了一个更好的方法。而不仅仅是一个弹出对话框。我们可以使用js填充表单字段

演示地点:

html

空指针反射导致了这样的错误。移除em

<table class="data-table" id="test">
  <thead>
     <tr>
        <th>Student ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Year Level</th>
    </tr>
  </thead>

学生证
名字
姓
年度水平
NULL指针反射导致了这种情况。移除em
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js" type="text/javascript"></script>
<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js" type="text/javascript"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
      <style>
     body {
  font-size: 62.5%;
       }
          label, input {
                 display: block;
              }
          input.text {
                margin-bottom: 12px;
                      width: 95%;
                       padding: .4em;
                    }
          fieldset {
             padding: 0;
             border: 0;
              margin-top: 25px;
       }
            h1 {
           font-size: 1.2em;
            margin: .6em 0;
           }
                   div#users-contain {
                    width: 350px;
                      margin: 20px 0;
                }
        div#users-contain table {
           margin: 1em 0;
         border-collapse: collapse;
           width: 100%;
     }
        div#users-contain table td, div#users-contain table th {
               border: 1px solid #eee;
              padding: .6em 10px;
              text-align: left;
                  }
   .ui-dialog .ui-state-error {
             padding: .3em;
   }
  .validateTips {
  border: 1px solid transparent;
    padding: 0.3em;
  }
    #dialog-form {
       display: none;
   }
      }
   </style>
   Warning:   StandardWrapperValve[StudentServlet]: Servlet.service() for servlet StudentServlet   threw exception
            java.lang.NumberFormatException: null
            at java.lang.Integer.parseInt(Integer.java:542)
            at java.lang.Integer.parseInt(Integer.java:615)
            at com.joseph.controller.StudentServlet.processRequest(StudentServlet.java:35)
            at com.joseph.controller.StudentServlet.doGet(StudentServlet.java:84)    
  <h1>Student Info:</h1>

  <form class="data-form">
<label>Student ID
    <input type="text" />
</label>
<label>First Name
    <input type="text" />
</label>
<label>Last Name
    <input type="text" />
  </label>
 <label>Year Level
    <input type="text" />
  </label>
 </form>
 <table class="data-table" id="test">
  <thead>
     <tr>
        <th>Student ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Year Level</th>
    </tr>
  </thead>
<tr>
    <td>1</td>
    <td>Frank</td>
    <td>Sinatra</td>
    <td>5</td>
</tr>
<tr>
    <td>2</td>
    <td>Miles</td>
    <td>Davis</td>
    <td>4</td>
   </tr>
    <tr>
    <td>3</td>
    <td>Tom</td>
    <td>Waits</td>
    <td>6</td>
  </tr>
 </table>
  $(document).ready(function () {
$("td", this).on("click", function () {
    var tds = $(this).parents("tr").find("td");
    $.each(tds, function (i, v) {
        $($(".data-form input")[i]).val($(v).text());
    });
});
});
<table class="data-table" id="test">
  <thead>
     <tr>
        <th>Student ID</th>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Year Level</th>
    </tr>
  </thead>