让复选框生动起来

原文链接:http://www.cnblogs.com/tanghuawei/archive/2007/01/12/618906.html
复选框内包含了检查符号,表示男

复选框内未包含检查符号,表示女


    我们来改进一下复选框。选中性别复选框,单击在属性表“事件/单击”右边的生成器按钮,选择代码生成器,就出现了代码的编辑窗口。写入如下程序:

Private Sub 性别_Click()

    注释:根据复选框的值显示男或女

    If (Me![性别] = -1) Then       注释:如果“是”就把标签改成“男”
      Me![性别标签].Caption = "男"
    End If

    If (Me![性别] = 0) Then        注释:如果“否”就把标签改成“女”
      Me![性别标签].Caption = "女"
    End If

End Sub

    以上这段程序能在单击复选框时自动改编标签显示的内容。为了在移动记录时正确显示性别,还需要在窗体的“事件/成为当前”里把这段程序再写一遍。

Private Sub Form_Current()

    注释:根据复选框的值显示男或女

    If (Me![性别] = -1) Then       注释:如果“是”就把标签改成“男”
      Me![性别标签].Caption = "男"
    End If

    If (Me![性别] = 0) Then        注释:如果“否”就把标签改成“女”
      Me![性别标签].Caption = "女"
    End If

End Sub

转载于:https://www.cnblogs.com/tanghuawei/archive/2007/01/12/618906.html

展开阅读全文
博主设置当前文章不允许评论。

复选框选中的问题

09-26

[code=Java] rn<%rn String op = myprog.getParam( "op" );rn if(op.equals( "op_edit"))rn rn String record_id = myprog.getParam( "record_id" );rn //System.out.println(record_id);rn sSql = "SELECT msg_id FROM S_Msg WHERE record_id='" + record_id + "'";rn System.out.println(sSql);rn String td[][] = db.selectA( sSql );rn String msg_id = td[0][0];rn sql="select rec_emp_name from S_RecMsg where msg_id='"+msg_id+"'";rn String emp_name[][] = db.selectA( sql );rn System.out.println(sql);rn //var checkboxs=document.getElementsByName("rec_emp_name"); rn for(int i=0;irn<%!rnString sSql="";rnString sql="";rnrn//=============================================================================rn//扩展列表分页显示类rn//=============================================================================rnrnclass myListTable extends jbs.html.listTable rn public String getSelect(String curName)rn rn String record_id = myprog.getParam( "record_id" );rn //System.out.println(record_id);rn sSql = "SELECT msg_id FROM S_Msg WHERE record_id='" + record_id + "'";rn System.out.println(sSql);rn String td[][] = db.selectA( sSql );rn String msg_id = td[0][0];rn sql="select rec_emp_name from S_RecMsg where msg_id='"+msg_id+"'";rn String emp_name[][] = db.selectA( sql );rn System.out.println(sql);rn String returnValue = ""; rn for(int i = 0; i < emp_name.length; ++i)rn rn if(emp_name[i][0].equals(curName))rn rn returnValue = "checked"; rn break; rn rn rn return returnValue; rn rn //系统查询数据库后,在生成页面前,自动调用此方法rn //可对结果集进行处理,提供如下变量可供使用:rn //resultRow 结果行数,resultCol 结果列数,resultData[][]查询结果二维数组rn public void BeforeMakeTable() rn for( int i=0; i" + resultData[i][1];rn String sql="select emp_id,emp_name from S_Emp where dep_id='"+temp_id+"'";rn rn String emp[][] = db.selectA(sql);rn resultData[i][1]="";rn for(int x=0; x<(emp.length); x++)rn rn rn if(!emp[x][0].equals(""))rn rn resultData[i][1] += "" + emp[x][1]+"";rn rn rn rn rn //备注rn // resultData[i][2] = "";rnrn rn rnrn//结束类定义rnrn%>rnrn<%rnString searchWhere = "";//查询SQL WHERE条件rnString searchUrl = ""; //获取分页的附加参数rnrnrn//表格字段名称, 宽度, 对齐rnString tbTitle[][] = new String[][] rn "部门", "5%", "left" ,rn "员工", "50%", "left" ,rn// "选择", "5%", "left" ,rn// "员工", "10%", "center" ,rn// "员工", "10%", "left" ,rnrn // "员工", "10%", "left" ,rnrn;rnrnrn//定义显示数据rn//或者从数据库直接查询而来, 如 String tbData[][] = db.selectA( SQL );rnsSql = "select dep_id,dep_name from S_Dep order by record_id";rnString tbData[][] = db.selectA( sSql );rnrn//需要隐藏的字段rnint tbHidden[] = new int[] rn 10rn;rnrn//附加查询SQL WHERE 条件rnString tbWhere = searchWhere;rnrnmyListTable ap = new myListTable();rn//ap.addForm( "form_table", "", "return false;" );//增加FORMrnap.setEnv( pageContext, db );//传入JSP页面对象, 数据库对象rnap.setTitle( tbTitle );//传入字段标题rnap.setChooseType( 0 );//第0列显示方式:0/正常,1/单选框,2/多选框rnap.setShowRecordNum( 9999 );//每页显示记录数rn//ap.setSQL( tbFields, tbSqlFields, "V_Yf_Product_Detail", tbWhere, tbOrder );//字段,表名,SQL WHERE条件,SQL排序rn//改为直接传入数据rnap.setData( tbData ); //必须, 传入查询结果集rn//ap.setPostUrl( searchUrl );//分页附加条件rnap.setHidden( tbHidden ); //隐藏rn//ap.setDefaultValue( myprog.getParam( "defaultClickValue" ) ); //缺省选中值rnap.showNavigate( false );//显示导航条rnrnString sHtml = ap.getHtml();//输出结果rnrn//=============================================================================rn//输出页面rn//=============================================================================rnrnmytpl.setParam( "TO_DETAIL", sHtml );rn%>rnrn[/code]rnrn这是整个JSP代码,怎样把让rec_emp_name复选框的value等于emp_name[i][]时让它选中?请各位高手帮忙解答一下 论坛

没有更多推荐了,返回首页