Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.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在JSP中使用onchange事件select更改html表单元素的值_Javascript_Java_Html_Jsp - Fatal编程技术网

如何使用或不使用javascript在JSP中使用onchange事件select更改html表单元素的值

如何使用或不使用javascript在JSP中使用onchange事件select更改html表单元素的值,javascript,java,html,jsp,Javascript,Java,Html,Jsp,var userArray=''; 函数setData() { 对于(变量i=0;i 0) { document.getElementById('userName').text=selectedUser.getUserName(); document.getElementById('userPassword')。text=selectedUser.getUserPassword(); document.getElementById('userType')。value=selectedUser.g


var userArray='';
函数setData()
{
对于(变量i=0;i 0)
{
document.getElementById('userName').text=selectedUser.getUserName();
document.getElementById('userPassword')。text=selectedUser.getUserPassword();
document.getElementById('userType')。value=selectedUser.getUserType();
document.getElementById('branchId')。value=selectedUser.getBranchId();
}
}

更新用户页面
更新用户


用户Id:

用户名:

用户密码:

用户类型: 出纳员 分行经理 管理员 银行职员 事务管理器

分支机构Id:


使用纯java脚本的一种方法是创建一个额外的输入(type=hidden)字段并将其添加到表单中

<form id="updateUserForm" method="post" >
....     
<input type="hidden" name="userVal" id="userVal">
...
</form>
或者,您可以使用setParameter方法,因为您的所有值都是字符串而不是对象

在JSP中,可以使用

<input id="userName" type="text" value="${userName}" >


我希望这会有所帮助。

发布您的尝试,*不起作用`不是解释问题的正确方式…您自己尝试过任何东西吗。请稍候,我将为您添加更多图像,以了解更多信息。不要简单地添加图像,发布实际代码!我不能再添加2张图片,因为我现在没有10个声誉。我是新来的
....

Integer userId = Integer.parseInt(request.getParameter("userVal"));

//get user data from the database based on userId and store them in your   request object

....//Access DB here
request.setAttribute("userName", userName);//userName fetched from your DB
request.setAttribute("userPsw", userPsw);//userPsw fetched from your DB 
<input id="userName" type="text" value="${userName}" >