新手请教一个显示图片的问题
现在jsp网页上实现这样的功能:一个下拉菜单对应值1、2、3;
如果下拉菜单选1,点击显示按钮,显示1.JPG图片;
下拉菜单选2,点击显示按钮,显示2.JPG图片;
下拉菜单选3,点击显示按钮,显示3.JPG图片;
知道的大哥们麻烦赐教。谢谢啦~~
//javascript代码 function pic(){ if($('#slt').val()==1){ $('#img').attr('src',"图片地址"); } if($('#slt').val()==2){ $('#img').attr('src',"图片地址"); }...... }
//页面 <select id='slt'> <option>1</option> <option>2</option> <option>3</option> </select> <input type="button" onclick='pic()'/> <img src="" id="img" />
<%@ page errorPage="/common/errorPage.jsp" %> <%@ page import="*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import="com.tjsoft.util.log.*"%> <%@ page import="com.tjsoft.jc.constant.*"%> <!--本页面用到的类包--> <%@ page import="com.tjsoft.jc2.bl.pub.CountBean"%> <%@ page import="com.tjsoft.jc.datawai.*"%> <%@ page import="com.tjsoft.jc.appwai.vote.*"%> <%@ page import="com.tjsoft.jc.appwai.index.*"%> <%@ page import="com.tjsoft.jc2.po.*"%> <%@ page import="com.tjsoft.jc.datawai.CPermissionitem"%> <%@ page import="com.tjsoft.util.CEncodeSwitch"%> <%@ page import="com.tjsoft.util.CHtmlEncode"%> <%@ include file="/include/jsp/tjwPCommon.jsp" %> <%@ page import="com.tjsoft.jc.data.CDepartment"%> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <jsp:useBean id="permissionitem" scope="request" class="com.tjsoft.jc.appwai.permissionitem.CPermissionControl" /> <jsp:useBean id="department" scope="request" class="com.tjsoft.jc.appwai.manager.CDepartmentControl" /> <html> <head> <title>aaaaa</title> <SCRIPT language="javascript"> function chkUser(){ if($('#years').val()==2010 && $('#months').val()==1){ var img= "/img-test/1.jpg"; } if($('#years').val()==2010 && $('#months').val()==2){ var img= "/img-test/2.jpg"; } } </script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <style type="text/css"> <!-- @import url("/images/index.css"); --> </style></head> <body style="overflow-x:hidden" bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> </table> <TABLE border=0 cellSpacing=0 cellPadding=0 width=290 align=center> <TBODY> <TR> <TD height=40 background=img-test/tu11.jpg align=right> 年<SELECT id=years name=years> <OPTION selected value=2012>2012</OPTION> <OPTION value=2011>2011</OPTION> <OPTION value=2010>2010</OPTION></SELECT> 月 <SELECT id=months name=months> <OPTION selected value=9>9</OPTION> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION value=5>5</OPTION> <OPTION value=6>6</OPTION> <OPTION value=7>7</OPTION> <OPTION value=8>8</OPTION> <OPTION value=10>10</OPTION> <OPTION value=11>11</OPTION> <OPTION value=12>12</OPTION></SELECT> <INPUT onclick=chkUser(); value=查找 type=button> </TD></TR></TBODY></TABLE> <TABLE width=400 height="285" border=0 align=center cellPadding=0 cellSpacing=0 class=kuang> <TBODY> <TR> <TD height=193> <TABLE border=0 cellSpacing=0 cellPadding=0 width="93%" align=center height=196> <TBODY> <TR> <TD vAlign=top> <TABLE class=codeview border=0 cellSpacing=2 cellPadding=0 width="98%" align=center> <TBODY> <TR> <TD onmouseover=r(this) onmouseout=w(this) width=350> <DIV id=first><IMG style="BORDER-BOTTOM-COLOR: white; BORDER-TOP-COLOR: white; BORDER-RIGHT-COLOR: white; BORDER-LEFT- COLOR: white" src=<% img %> width=400 height=260> </DIV> <DIV id=sea> </DIV> </TD> </TR> </TBODY> </TABLE> </TD> </TR> </TBODY> </TABLE> </TD> </TR> </TBODY> </TABLE><!-- start11 --> </body> </html>那有该如何显示呢??我上面这样写,报错了。