大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
你这个不能这样写
创新互联公司是一家专业提供琅琊企业网站建设,专注与做网站、网站制作、H5网站设计、小程序制作等业务。10年已为琅琊众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。
你只能用ajax来做 只要其他条件变动 就触发请求访问后台 然后后台根据条件查询相应的出票方,以json格式传到前台,然后解析用js放入相应的select标签
至于ajax二级联动 你自己百度下 一大把 原理都是ajax请求 js解析放入相应的标签
你可以通过 jquery 的ajax 访问后台获取 json数据 。这样就可以直接把 传过来的接送数据 赋值给proData
还可以通过纯jsp的方法
%
JSONObject json = JSONObject.fromObject(你访问你后台的方法返回的字符串数据);
%
在js里面
var proData = eval("(%=json %)")
java中要实现二级联动,应该使用ajax技术,实例如下:
var req;
function chooseEmp()
{
var emp= document.getElementById('empId');
var url = "MagEmp?emp="+escape(emp.value);
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
}else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if(req){
req.open("GET", url, true);
req.onreadystatechange = callback;
req.send(null);
}
}
function callback()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
parseMessage();
}else{
alert("Not able to retrieve description"+req.statusText);
}
}
}
function parseMessage()
{
var xmlDoc=req.responseXML.documentElement;
var xSel=xmlDoc.getElementsByTagName('select');
var select_root=document.getElementById('magId');
select_root.options.length=0;
for(var i=0;ixSel.length;i++)
{
var xValue=xSel[i].childNodes[0].firstChild.nodeValue;
var xText=xSel[i].childNodes[1].firstChild.nodeValue;
var option=new Option(xText,xValue);
try{
select_root.add(option);
}catch(e){
}
}
}
//:ComboBoxText.java
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class ComboBoxText {
private String[][] xxx = {
{"浙江","杭州","温州","绍兴","舟山",},
{"江苏","南京","无锡","徐州","蒙眬",},
{"上海","闵行区","普陀区","金山区",},
};
private Object[] a(){
Object[] os = new Object[xxx.length];
for(int i=0; ixxx.length; i++){
os[i]=xxx[i][0];
}
return os;
}
private Object[] b(Object a){
for(int i=0; ixxx.length; i++){
if(xxx[i][0].equals(a)){
Object[] o = new Object[xxx[i].length-1];
for(int j=0; jo.length; j++)
o[j]=xxx[i][j+1];
return o;
}
}
return new Object[]{};
}
public static void main(String[] args) {
final ComboBoxText ct = new ComboBoxText();
final JComboBox ca = new JComboBox(ct.a());
final JComboBox cb = new JComboBox();
ca.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
cb.removeAllItems();
Object selected = ca.getSelectedItem();
Object[] newItems = ct.b(selected);
for(int i=0; inewItems.length; i++)
cb.addItem(newItems[i]);
}
});
ca.setSelectedIndex(-1);
JFrame f = new JFrame();f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().setLayout(new FlowLayout(FlowLayout.LEFT));
f.add(ca);f.add(cb);f.setVisible(true);
f.setSize(200,100);
}
}
%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%
html
head
title/title
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
style
body,select
{
font-size:9pt;
font-family:Verdana;
}
a
{
color:red;
text-decoration:none;
}
a:hover{
text-decoration:underline;
}
/style
SCRIPT LANGUAGE="JavaScript"
!--
function Dsy()
{
this.Items = {};
}
Dsy.prototype.add = function(id,iArray)
{
this.Items[id] = iArray;
}
Dsy.prototype.Exists = function(id)
{
if(typeof(this.Items[id]) == "undefined") return false;
return true;
}
function change(v){
var str="0";
for(i=0;iv;i++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
var ss=document.getElementById(s[v]);
with(ss){
length = 0;
options[0]=new Option(opt0[v],opt0[v]);
if(v document.getElementById(s[v-1]).selectedIndex0 || !v)
{
if(dsy.Exists(str)){
ar = dsy.Items[str];
for(i=0;iar.length;i++)options[length]=new Option(ar[i],ar[i]);
if(v)options[1].selected = true;
}
}
if(++vs.length){change(v);}
}
}
var dsy = new Dsy();
dsy.add("0",["1","2","3","4"]);
dsy.add("0_0",["11","12","13"]);
dsy.add("0_1",["21","22","23"]);
dsy.add("0_2",["31","32","33"]);
dsy.add("0_3",["41","42","43"]);
//--
/SCRIPT
SCRIPT LANGUAGE = JavaScript
var s=["s1","s2"];
var opt0 = ["请选择","请选择"];
function setup()
{
for(i=0;is.length-1;i++)
document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
change(0);
}
//--
/SCRIPT
/head
body bgcolor="#E0E0E0" onload="setup()"
form name="frm" action="11.jsp"
select id="s1" name="s1"option/option/select
select id="s2" name="s2"option/option/select
input type="submit" name="Submit" value="提交"
/form
/body
/html
11.jsp
html
head
meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"
titleInsert title here/title
/head
body
%
String s1 = request.getParameter("s1");
String s2 = request.getParameter("s2");
out.println(s1);
out.println(s2);
%
/body
/html