显示与不显示的例子

完成的功能
点击显示按钮显示出来来电的对话框
点击不显示按钮把来电的对话框隐藏起来

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>


<script type="text/javascript">
  		var tt =0;

 function v_old(num){
   		tt = tt+num;
   		var tt1 = tt%2;
   		if(tt1>0){
   			document.getElementById("old").style.display='';
   			document.getElementById("button1").style.display='';
   			document.getElementById("button2").style.display='none';
   		}else if(tt1==0){
   			document.getElementById("old").style.display='none';
   			document.getElementById("button2").style.display='';
   			document.getElementById("button1").style.display='none';
   		}
   		
   }

</script>
<body>
<div class="laidian">
  <ul>
  
  <li>
  <div id="old" style="display:none"><span class="span_font">来电号码:</span>&nbsp;<input type="text" name ="telno" value="${requestScope.telno}"size="15" maxlength="23" class="input_edit"/>	
  </div>
  </li>
  <li>
   		<input type="button" class="button3" name ="view" value="不显示"  onclick="v_old(1)" id="button1"/>
   		<input id="button2" type="button" class="button3" name ="view" value="显示"  onclick="v_old(1)" style="display:none"/>
  </li>
</body>

</html>

你可能感兴趣的:(java,apache,jsp,struts,sun)