社区
Web 开发
帖子详情
问题请教
zhbw
2004-09-30 10:09:56
请问如何实现第二个下拉框的内容随第一个下拉框的内容变化而变化的
...全文
92
4
打赏
收藏
问题请教
请问如何实现第二个下拉框的内容随第一个下拉框的内容变化而变化的
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
zhbw
2004-10-01
打赏
举报
回复
多谢,多谢,谢
风斧
2004-10-01
打赏
举报
回复
我觉得楼上的效果可以用javascript来实现,如果涉及到后台数据的刷新,applet就不行了吧。可以有一个提交的操作来解决。
lanleer
2004-09-30
打赏
举报
回复
我来个简单得例子
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JComboBoxSample extends JFrame implements ItemListener
{
Container ctp=getContentPane();
JLabel lb1=new JLabel("类型:");
String obj[]={"铅笔","钢笔"},
type1[]={"A","B","C"},
type2[]={"E","F","G"};
JComboBox cbx=new JComboBox();
JComboBox cbx2=new JComboBox();
public JComboBoxSample()
{
ctp.setLayout(new FlowLayout());
for (int n=0;n<obj.length;n++)
cbx.addItem(obj[n]);
ctp.add(cbx);
cbx.addItemListener(this);
ctp.add(lb1);
ctp.add(cbx2);
for (int n=0;n<type1.length;n++)
cbx2.addItem(type1[n]);
}
public void itemStateChanged(ItemEvent e)
{
int x=0,y;
String ko=(String)e.getItem();
for (y=0;y<type1.length;y++)
x=cbx.getSelectedIndex();
System.out.println(x);
if (x==1)
{
cbx2.removeAllItems();
for (int n=0;n<type2.length;n++)
cbx2.addItem(type2[n]);
}
if (x==0)
{
cbx2.removeAllItems();
for (int n=0;n<type1.length;n++)
cbx2.addItem(type1[n]);
}
}
public static void main(String []args)
{
JComboBoxSample jcb=new JComboBoxSample();
jcb.setSize(310,150);
jcb.setVisible(true);
}
}
hbuzhang
2004-09-30
打赏
举报
回复
给你个例子你研究一下:
<html>
<head>
<title>无标题文档</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<script language="javascript">
cityareaname=new Array(35);
cityareacode=new Array(35);
function first(preP,preC,formname,selectP,selectC)
{
a=0;
if (selectP=='01')
{ a=1;tempoption=new Option('北京','01',false,true); }
else
{ tempoption=new Option('北京','01'); }
eval('document.'+formname+'.'+preP+'.options[1]=tempoption;');
cityareacode[0]=new Array('0101','0102','0103','0104','0105','0106','0107','0108');
cityareaname[0]=new Array('东城区','西城区','崇文区','宣武区','朝阳区','海淀区','丰台区','石景山');
if (selectP=='02')
{ a=2;tempoption=new Option('深圳','02',false,true); }
else
{ tempoption=new Option('深圳','02'); }
eval('document.'+formname+'.'+preP+'.options[2]=tempoption;');
cityareacode[1]=new Array('0201','0202','0203','0204','0205','0206');
cityareaname[1]=new Array('罗湖','福田','南山','盐田','宝安','龙岗');
if (selectP=='03')
{ a=3;tempoption=new Option('上海','03',false,true); }
else
{ tempoption=new Option('上海','03'); }
eval('document.'+formname+'.'+preP+'.options[3]=tempoption;');
cityareacode[2]=new Array('0301','0302','0303','0304','0305','0306','0307','0308','0309','0310','0311','0312','0313','0314','0315','0316','0317','0318','0319','0320');
cityareaname[2]=new Array('宝山','金山','南市','长宁','静安','青浦','崇明','卢湾','松江','奉贤','浦东','杨浦','虹口','普陀','闸北','黄浦','闵行','徐汇','嘉定','南汇');
eval('document.'+formname+'.'+preP+'.options[33]=tempoption;');
cityareacode[32]=new Array();
cityareaname[32]=new Array();
if (selectP=='34')
{ a=34;tempoption=new Option('澳门','34',false,true); }
else
{ tempoption=new Option('澳门','34'); }
eval('document.'+formname+'.'+preP+'.options[34]=tempoption;');
cityareacode[33]=new Array();
cityareaname[33]=new Array();
if (selectP=='35')
{ a=35;tempoption=new Option('台湾','35',false,true); }
else
{ tempoption=new Option('台湾','35'); }
eval('document.'+formname+'.'+preP+'.options[35]=tempoption;');
cityareacode[34]=new Array();
cityareaname[34]=new Array();
eval('document.'+formname+'.'+preP+'.options[a].selected=true;');
cityid=selectP;
if (cityid!='0')
{
b=0;for (i=0;i<cityareaname[cityid-1].length;i++)
{
if (selectC==cityareacode[cityid-1][i])
{b=i+1;tempoption=new Option(cityareaname[cityid-1][i],cityareacode[cityid-1][i],false,true);}
else
tempoption=new Option(cityareaname[cityid-1][i],cityareacode[cityid-1][i]);
eval('document.'+formname+'.'+preC+'.options[i+1]=tempoption;');
}
eval('document.'+formname+'.'+preC+'.options[b].selected=true;');
}
}
function selectcityarea(preP,preC,formname)
{
cityid=eval('document.'+formname+'.'+preP+'.selectedIndex;');
j=eval('document.'+formname+'.'+preC+'.length;');
for (i=1;i<j;i++)
{eval('document.'+formname+'.'+preC+'.options[j-i]=null;')}
if (cityid!="0")
{
for (i=0;i<cityareaname[cityid-1].length;i++)
{
tempoption=new Option(cityareaname[cityid-1][i],cityareacode[cityid-1][i]);
eval('document.'+formname+'.'+preC+'.options[i+1]=tempoption;');
}
}
}
</script>
<form action="file:///C|/Program%20Files/Macromedia/Dreamweaver%204/Lessons/Lesson%20Files/info_search.asp?martid=" method=post name=form1>
<img src="file:///C|/Program%20Files/Macromedia/Dreamweaver%204/images/w_KT.gif" height="6" width="1"><br>
<table width=300 border=0 cellspacing="0" cellpadding="1" !bgcolor=#FFFDE6>
<tr>
<td class="black_con9" align="right">省份:</td>
<td class="black_con9">
<select name="selectp" onChange="selectcityarea('selectp','selectc','form1');">
<option value="0" selected>省份</option>
</select>
</td>
</tr>
<tr>
<td class="black_con9" align="right">县/市:</td>
<td class="black_con9">
<select name="selectc">
<option value="0" selected>县/市</option>
</select>
</td>
</tr>
</table>
</form>
<script language="javascript">
first("selectp","selectc","form1",0,0);
</script>
</body>
</html>
P
问题
、NP
问题
、NPC
问题
、NP hard
问题
图论算法摘要 1. 图的概念 图 一个图(graph) G=(V,E)G=(V,E)G=(V,E) 由顶点(vertex)集 VVV 和边(edge)集 EEE 组成。 每一条边就是一个点对 (a,b),a,b∈V(a,b),a,b∈V(a,b),a,b∈V。有时候也把边叫做弧(arc)。 有向图 如果点对(a,b),a,b∈V(a,b),a,b∈V(a,b),a,b∈V是有序的,那么图就是有向的...
P
问题
,NP
问题
,NPC
问题
,NPH
问题
概念。’0/1背包判定
问题
是NPC
问题
‘和‘0/1背包
问题
是NPH
问题
但不是NPC
问题
’以及碰撞集是NPC
问题
‘证明。
(2)b个点的vertex cover 集 对应规模大小为b的碰撞集 :对于每一条边,至少有一个端点在b个点的vertex cover集 中,所以这个集合和。(1)构建图G为碰撞集的映射:其中图G的每一个点对应碰撞集的每个元素,每条边对应。(3)规模大小为b的碰撞集对应b个点的vertex cover集:任意的。但0/1背包判定
问题
是NPC
问题
,0/1背包
问题
不比其更容易,所以,它是NPH
问题
。综上所述,顶点覆盖
问题
可以归约到碰撞集,因此碰撞集也是NPC
问题
。,在多项式时间内可以完成,故碰撞集是NP
问题
。
什么是P
问题
、NP
问题
和NPC
问题
这或许是众多OIer最大的误区之一。 你会经常看到网上出现“这怎么做,这不是NP
问题
吗”、“这个只有搜了,这已经被证明是NP
问题
了”之类的话。你要知道,大多数人此时所说的NP
问题
其实都是指的NPC
问题
。他们没有搞清楚NP
问题
和NPC
问题
的概念。NP
问题
并不是那种“只有搜才行”的
问题
,NPC
问题
才是。好,行了,基本上这个误解已经被澄清了。下面的内容都是在讲什么是P
问题
,什
一文看懂P
问题
,NP
问题
,NPC
问题
一文读懂P
问题
,NP
问题
,NPC
问题
,以及P=NP?
问题
,NP-Hard
问题
,NPC
问题
的证明等
P
问题
,NP
问题
,NP难
问题
转自:https://blog.csdn.net/csshuke/article/details/74909562 有一则程序员界的笑话,就是有一哥们去google面试的时候被问到一个
问题
是:在什么情况下P=NP,然后他的回答是”当N=1的时候”。这是我第一次听说P=NP
问题
,大概是在临近毕业为找工作而准备的时候。 这几天科技类新闻的头条都被阿尔法狗大战李世石刷爆了,虽然我也不是AI专家,但是...
Web 开发
81,108
社区成员
341,721
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章