【问题标题】:JSP Select Option onchange query DB and show in TextBox same pageJSP 选择选项 onchange 查询数据库并显示在 TextBox 同一页面中
【发布时间】:2012-09-24 13:49:23
【问题描述】:

在我的 jsp 文件中,项目名称显示如下。

<label for="email">Project Name</label> 
<select name='project_name' class='required input_field' id='project_name'>
<option value=''>-- Select --</option>
<c:forEach var="row" items="${result.rows}">
<option value="${row.ProjectId}">${row.ProjectName}</option>
</c:forEach>
</select>

我的问题是,我想在选择选项下方的文本框中显示相应项目的客户端名称。

<label for="author">Client Name</label>
<input type='text' name='client_name' id='client_name' class='required input_field' style='width:260px;'>

我希望它显示选择选项的 onchange。 为此,我必须查询数据库。我该怎么做..

【问题讨论】:

    标签: javascript jsp jdbc java-ee-6


    【解决方案1】:

    您可以将onchange 属性添加到您的select,其中包含:

    this.form['client_name'].value = this[this.selectedIndex].innerText
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      相关资源
      最近更新 更多