Javascript 基于单个文本框值自动填充多个文本框
我有三个文本框,当我在第一个文本框中写东西时,我会将值发送到state.jsp并像这样显示它 out.println(firsttextboxvalue);通过第二个文本框响应ID。但我想在第一个文本框中的onkeyup事件中,将第三个文本框填充为不同的响应值。我怎样才能做到呢 auto.jsp state.jspJavascript 基于单个文本框值自动填充多个文本框,javascript,jquery,ajax,jsp,Javascript,Jquery,Ajax,Jsp,我有三个文本框,当我在第一个文本框中写东西时,我会将值发送到state.jsp并像这样显示它 out.println(firsttextboxvalue);通过第二个文本框响应ID。但我想在第一个文本框中的onkeyup事件中,将第三个文本框填充为不同的响应值。我怎样才能做到呢 auto.jsp state.jsp 任何帮助我不知道jsp编码,但可以这样做: <% String firsttextbox=request.getParameter("count");
任何帮助我不知道jsp编码,但可以这样做:
<%
String firsttextbox=request.getParameter("count");
String 3rdtextbox="3rd textbox value";
out.println(firsttextbox+'|'+3rdtextbox);// + for concatenation ?
%>
对不起,我今晚没有时间再给你写一个答案,但是,您应该考虑以JSON格式从jsp返回数据,因为这为您提供了一种将多个值编码为同一字符串的简单方法,以便您可以轻松地在JavaScript中提取它们。好的nnnnnn我正在尝试,但如果您有时间,请帮我提供答案,我迫切需要它。谁能给我提供答案呢?@nnnnnn你能举个例子告诉我json格式吗?@Valky谢谢你的回答。我之前已经找到了我问题的解决方案,无论如何,我已经对你的答案投了赞成票
<%
String firsttextbox=request.getParameter("count");
out.println(firsttextbox); //displayed in 2nd textbox plus it is also showing the below 3rdtextbox value, but i want to display out.println(firsttextbox); by 2nd textbox id only
String 3rdtextbox="3rd textbox value";
out.println(3rdtextbox); // it also displayed 3rdtextbox value plus it is also showing the 2nd textbox value
//How can i separate these two outputs so that `first println() will be displayed in 2nd textbox and 3rd println() will be displayed in 3rd text box?`
%>
<%
String firsttextbox=request.getParameter("count");
String 3rdtextbox="3rd textbox value";
out.println(firsttextbox+'|'+3rdtextbox);// + for concatenation ?
%>
$("#textbox1").keyup(function() {
$.get('state.jsp', {count : this.value}, function(responseData) {
result=responseData.split('|');
$("#textbox2").val(result[0]);
$("#textbox3").val(result[1]);
});
});