码迷,mamicode.com
首页 > Web开发 > 详细

js小技巧

时间:2017-06-16 11:31:03      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:color   也有   turn   encoding   tar   change   exe   doctype   round   

  • 页面传递string给后台特殊字符转换,如:"+"转换为"%2B"

  • 城市选择

    • 技术分享
      <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
      <%@ taglib prefix="s" uri="/struts-tags"%>
      
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <style type="text/css">
      BODY {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      DIV {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      DL {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      DT {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      DD {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      UL {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      OL {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      LI {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      H1 {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      H2 {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      
      P {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      
      LI {
          LIST-STYLE-TYPE: none; LIST-STYLE-IMAGE: none
      }
      
      H2 {
          FONT-SIZE: 100%
      }
      
      #change-city{width:1000px; margin:10px auto;}
      #change-city .choosecities {
          BORDER-BOTTOM: #a3d7df 1px solid; BORDER-LEFT: #a3d7df 1px solid; PADDING-BOTTOM: 60px; BACKGROUND: #fff; BORDER-TOP: #a3d7df 1px solid; BORDER-RIGHT: #a3d7df 1px solid; box-shadow: 0 0 1px #d4edf4
      }
      #change-city .choosecities A:hover {
          TEXT-DECORATION: none
      }
      
      #change-city .citieslist H2 {
          POSITION: relative; PADDING-BOTTOM: 0px; LINE-HEIGHT: 30px; MARGIN: 20px 20px 12px; PADDING-LEFT: 14px; PADDING-RIGHT: 14px; ZOOM: 1; DISPLAY: inline-block; BACKGROUND: #00c7c7; HEIGHT: 32px; COLOR: #fff; PADDING-TOP: 0px; border-radius: 0
      }
      #change-city .citieslist H2 SPAN {
          BORDER-BOTTOM: #fff 6px solid; POSITION: absolute; BORDER-LEFT: #fff 6px solid; LINE-HEIGHT: 0; WIDTH: 0px; DISPLAY: block; FLOAT: none; HEIGHT: 0px; FONT-SIZE: 0px; BORDER-TOP: #00c7c7 6px solid; TOP: 32px; BORDER-RIGHT: #fff 6px solid; LEFT: 20px
      }
      #change-city .citieslist LI {
          BORDER-BOTTOM: #fff 1px solid; BORDER-TOP: #fff 1px solid
      }
      #change-city .citieslist P {
          BORDER-BOTTOM: #fff 1px solid; PADDING-BOTTOM: 6px; PADDING-LEFT: 30px; PADDING-RIGHT: 10px; BORDER-TOP: #fff 1px solid; PADDING-TOP: 6px
      }
      #change-city .citieslist SPAN.label {
          BORDER-BOTTOM: #ddd 1px solid; BORDER-LEFT: #ddd 1px solid; LINE-HEIGHT: 24px; WIDTH: 30px; ZOOM: 1; DISPLAY: inline-block; HEIGHT: 30px; COLOR: #666; VERTICAL-ALIGN: top; BORDER-TOP: #ddd 1px solid; MARGIN-RIGHT: 5px; BORDER-RIGHT: #ddd 1px solid; border-radius: 0
      }
      #change-city .citieslist SPAN.label STRONG {
          BORDER-BOTTOM: #f7f7f7 1px solid; TEXT-ALIGN: center; BORDER-LEFT: #f7f7f7 1px solid; WIDTH: 28px; DISPLAY: block; FONT-FAMILY: Tahoma; BACKGROUND: #f1f1f1; HEIGHT: 28px; FONT-SIZE: 16px; BORDER-TOP: #f7f7f7 1px solid; BORDER-RIGHT: #f7f7f7 1px solid; border-radius: 0
      }
      #change-city .citieslist SPAN {
          WIDTH: 880px; ZOOM: 1; DISPLAY: inline-block; VERTICAL-ALIGN: top
      }
      #change-city .citieslist SPAN I {
          FONT-STYLE: normal; MARGIN: 0px 3px; COLOR: #ccc
      }
      #change-city .citieslist .hover {
          BORDER-BOTTOM-COLOR: #e5e5e5; BORDER-TOP-COLOR: #e5e5e5; BORDER-RIGHT-COLOR: #e5e5e5; BORDER-LEFT-COLOR: #e5e5e5
      }
      #change-city .citieslist .hover P {
          BACKGROUND: #f7f7f7
      }
      #change-city .citieslist .hover SPAN.label {
          BORDER-BOTTOM-COLOR: #1fb7bb; BORDER-TOP-COLOR: #1fb7bb; BORDER-RIGHT-COLOR: #1fb7bb; BORDER-LEFT-COLOR: #1fb7bb
      }
      #change-city .citieslist .hover SPAN.label STRONG {
          BORDER-BOTTOM-COLOR: #00c7c7; BORDER-TOP-COLOR: #00c7c7; BACKGROUND: #00c7c7; COLOR: #fff; BORDER-RIGHT-COLOR: #00c7c7; BORDER-LEFT-COLOR: #00c7c7
      }
      #change-city .citieslist A {
          PADDING-BOTTOM: 1px; LINE-HEIGHT: 20px; MARGIN: 5px 10px; PADDING: 5px 10px;  ZOOM: 1; DISPLAY: inline-block; HEIGHT: 20px;  border-radius: 0
      }
      #change-city .citieslist A:hover {
          BACKGROUND: #00c7c7; COLOR: #fff
      }
      #change-city .citieslist .isonline {
          FONT-WEIGHT: bold
      }
      #change-city .citieslist .isoffline {
          FONT-WEIGHT: bold
      }
      #bdw {
          MIN-HEIGHT: 500px
      }
      .cf {
          ZOOM: 1
      }
      .cf:after {
          DISPLAY: block; HEIGHT: 0px; VISIBILITY: hidden; CLEAR: both; OVERFLOW: hidden; CONTENT: ‘‘
      }
      H2 {
          PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px
      }
      
      BODY {
          FONT: 14px/1.5 Tahoma, Helvetica, arial, sans-serif; BACKGROUND: #d6e9ec; COLOR: #000
      }
      A {
          COLOR: #399; TEXT-DECORATION: none
      }
      A:hover {
          TEXT-DECORATION: underline
      }
      SPAN.money {
          FONT-FAMILY: arial
      }
      SPAN.required {
          COLOR: red
      }
      </style>
      <div>
      <input id=‘selectarea_str‘ type="hidden" value="<s:property value="#request.str"/>"/>
      <div id="change-city">
        <div id="bdw" class="bdw">
          <div id="bd" class="cf">
            <div class="choosecities">
              <div class="citieslist">
                <h2 align="left">按拼音首字母选择<span class="arrow">&raquo;</span></h2>
                <ol class="hasallcity">
                  <li id="city-A">
                    <p class="cf"><span class="label"><strong>A</strong></span><span><a class="isonline" onclick="selectThis(this.text);">鞍山</a><a class="isoffline" onclick="selectThis(this.text);">安顺</a><a class="isoffline" onclick="selectThis(this.text);">阿坝</a><a class="isoffline" onclick="selectThis(this.text);">阿拉善</a><a class="isoffline" onclick="selectThis(this.text);">阿里</a><a class="isoffline" onclick="selectThis(this.text);">安康</a><a class="isoffline" onclick="selectThis(this.text);">阿克苏</a><a class="isoffline" onclick="selectThis(this.text);">安庆</a><a class="isoffline" onclick="selectThis(this.text);">阿勒泰</a><a class="isoffline" onclick="selectThis(this.text);">安阳</a><a class="isoffline" onclick="selectThis(this.text);">澳门</a></span></p>
                  </li>
                  <li id="city-B">
                    <p class="cf"><span class="label"><strong>B</strong></span><span><a class="isonline" onclick="selectThis(this.text);">北京</a><a class="isonline" onclick="selectThis(this.text);">包头</a><a class="isoffline" onclick="selectThis(this.text);">保定</a><a class="isoffline" onclick="selectThis(this.text);">巴中</a><a class="isoffline" onclick="selectThis(this.text);">蚌埠</a><a class="isoffline" onclick="selectThis(this.text);">白银</a><a class="isoffline" onclick="selectThis(this.text);">白城</a><a class="isoffline" onclick="selectThis(this.text);">白山</a><a class="isoffline" onclick="selectThis(this.text);">北海</a><a class="isoffline" onclick="selectThis(this.text);">巴彦淖尔</a><a class="isoffline" onclick="selectThis(this.text);">宝鸡</a><a class="isoffline" onclick="selectThis(this.text);">百色</a><a class="isoffline" onclick="selectThis(this.text);">本溪</a><a class="isoffline" onclick="selectThis(this.text);">保山</a><a class="isoffline" onclick="selectThis(this.text);">毕节</a><a class="isoffline" onclick="selectThis(this.text);">博尔塔拉</a><a class="isoffline" onclick="selectThis(this.text);">滨州</a><a class="isoffline" onclick="selectThis(this.text);">亳州</a><a class="isoffline" onclick="selectThis(this.text);">巴州</a></span></p>
                  </li>
                  <li id="city-C">
                    <p class="cf"><span class="label"><strong>C</strong></span><span><a class="isonline" onclick="selectThis(this.text);">成都</a><a class="isonline" onclick="selectThis(this.text);">重庆</a><a class="isonline" onclick="selectThis(this.text);">常州</a><a class="isonline" onclick="selectThis(this.text);">长沙</a><a class="isonline" onclick="selectThis(this.text);">长春</a><a class="isoffline" onclick="selectThis(this.text);">赤峰</a><a class="isoffline" onclick="selectThis(this.text);">楚雄</a><a class="isoffline" onclick="selectThis(this.text);">长治</a><a class="isoffline" onclick="selectThis(this.text);">巢湖</a><a class="isoffline" onclick="selectThis(this.text);">崇左</a><a class="isoffline" onclick="selectThis(this.text);">潮州</a><a class="isoffline" onclick="selectThis(this.text);">昌吉</a><a class="isoffline" onclick="selectThis(this.text);">沧州</a><a class="isoffline" onclick="selectThis(this.text);">郴州</a><a class="isoffline" onclick="selectThis(this.text);">常德</a><a class="isoffline" onclick="selectThis(this.text);">滁州</a><a class="isoffline" onclick="selectThis(this.text);">朝阳</a><a class="isoffline" onclick="selectThis(this.text);">昌都</a><a class="isoffline" onclick="selectThis(this.text);">池州</a><a class="isoffline" onclick="selectThis(this.text);">承德</a></span></p>
                  </li>
                  <li id="city-D">
                    <p class="cf"><span class="label"><strong>D</strong></span><span><a class="isonline" onclick="selectThis(this.text);">东莞</a><a class="isonline" onclick="selectThis(this.text);">大连</a><a class="isonline" onclick="selectThis(this.text);">东营</a><a class="isoffline" onclick="selectThis(this.text);">大庆</a><a class="isoffline" onclick="selectThis(this.text);">大同</a><a class="isoffline" onclick="selectThis(this.text);">大理</a><a class="isoffline" onclick="selectThis(this.text);">德阳</a><a class="isoffline" onclick="selectThis(this.text);">迪庆</a><a class="isoffline" onclick="selectThis(this.text);">达州</a><a class="isoffline" onclick="selectThis(this.text);">德州</a><a class="isoffline" onclick="selectThis(this.text);">丹东</a><a class="isoffline" onclick="selectThis(this.text);">大兴安岭</a><a class="isoffline" onclick="selectThis(this.text);">德宏</a><a class="isoffline" onclick="selectThis(this.text);">定西</a></span></p>
                  </li>
                  <li id="city-E">
                    <p class="cf"><span class="label"><strong>E</strong></span><span><a class="isoffline" onclick="selectThis(this.text);">恩施</a><a class="isoffline" onclick="selectThis(this.text);">鄂州</a><a class="isoffline" onclick="selectThis(this.text);">鄂尔多斯</a></span></p>
                  </li>
                  <li id="city-F">
                    <p class="cf"><span class="label"><strong>F</strong></span><span><a class="isonline" onclick="selectThis(this.text);">福州</a><a class="isonline" onclick="selectThis(this.text);">佛山</a><a class="isonline" onclick="selectThis(this.text);">抚顺</a><a class="isoffline" onclick="selectThis(this.text);">阜阳</a><a class="isoffline" onclick="selectThis(this.text);">抚州</a><a class="isoffline" onclick="selectThis(this.text);">防城港</a><a class="isoffline" onclick="selectThis(this.text);">阜新</a></span></p>
                  </li>
                  <li id="city-G">
                    <p class="cf"><span class="label"><strong>G</strong></span><span><a class="isonline" onclick="selectThis(this.text);">广州</a><a class="isonline" onclick="selectThis(this.text);">贵阳</a><a class="isonline" onclick="selectThis(this.text);">桂林</a><a class="isoffline" onclick="selectThis(this.text);">赣州</a><a class="isoffline" onclick="selectThis(this.text);">广元</a><a class="isoffline" onclick="selectThis(this.text);">果洛</a><a class="isoffline" onclick="selectThis(this.text);">固原</a><a class="isoffline" onclick="selectThis(this.text);">甘南</a><a class="isoffline" onclick="selectThis(this.text);">甘孜</a><a class="isoffline" onclick="selectThis(this.text);">广安</a><a class="isoffline" onclick="selectThis(this.text);">贵港</a></span></p>
                  </li>
                  <li id="city-H">
                    <p class="cf"><span class="label"><strong>H</strong></span><span><a class="isonline" onclick="selectThis(this.text);">杭州</a><a class="isonline" onclick="selectThis(this.text);">哈尔滨</a><a class="isonline" onclick="selectThis(this.text);">合肥</a><a class="isonline" onclick="selectThis(this.text);">邯郸</a><a class="isonline" onclick="selectThis(this.text);">惠州</a><a class="isonline" onclick="selectThis(this.text);">海口</a><a class="isonline" onclick="selectThis(this.text);">呼和浩特</a><a class="isonline" onclick="selectThis(this.text);">衡阳</a><a class="isonline" onclick="selectThis(this.text);">湖州</a><a class="isoffline" onclick="selectThis(this.text);">淮北</a><a class="isoffline" onclick="selectThis(this.text);">鹤岗</a><a class="isoffline" onclick="selectThis(this.text);">海北</a><a class="isoffline" onclick="selectThis(this.text);">海东</a><a class="isoffline" onclick="selectThis(this.text);">黄南</a><a class="isoffline" onclick="selectThis(this.text);">菏泽</a><a class="isoffline" onclick="selectThis(this.text);">海南州</a><a class="isoffline" onclick="selectThis(this.text);">黑河</a><a class="isoffline" onclick="selectThis(this.text);">和田</a><a class="isoffline" onclick="selectThis(this.text);">哈密</a><a class="isoffline" onclick="selectThis(this.text);">淮安</a><a class="isoffline" onclick="selectThis(this.text);">淮南</a><a class="isoffline" onclick="selectThis(this.text);">黄山</a><a class="isoffline" onclick="selectThis(this.text);">海西</a><a class="isoffline" onclick="selectThis(this.text);">贺州</a><a class="isoffline" onclick="selectThis(this.text);">怀化</a><a class="isoffline" onclick="selectThis(this.text);">河池</a><a class="isoffline" onclick="selectThis(this.text);">呼伦贝尔</a><a class="isoffline" onclick="selectThis(this.text);">衡水</a><a class="isoffline" onclick="selectThis(this.text);">河源</a><a class="isoffline" onclick="selectThis(this.text);">红河</a><a class="isoffline" onclick="selectThis(this.text);">汉中</a><a class="isoffline" onclick="selectThis(this.text);">黄冈</a><a class="isoffline" onclick="selectThis(this.text);">黄石</a><a class="isoffline" onclick="selectThis(this.text);">鹤壁</a><a class="isoffline" onclick="selectThis(this.text);">葫芦岛</a></span></p>
                  </li>
                  <li id="city-J">
                    <p class="cf"><span class="label"><strong>J</strong></span><span><a class="isonline" onclick="selectThis(this.text);">济南</a><a class="isonline" onclick="selectThis(this.text);">济宁</a><a class="isonline" onclick="selectThis(this.text);">嘉兴</a><a class="isonline" onclick="selectThis(this.text);">金华</a><a class="isonline" onclick="selectThis(this.text);">焦作</a><a class="isonline" onclick="selectThis(this.text);">荆州</a><a class="isonline" onclick="selectThis(this.text);">吉林</a><a class="isonline" onclick="selectThis(this.text);">锦州</a><a class="isonline" onclick="selectThis(this.text);">江门</a><a class="isoffline" onclick="selectThis(this.text);">景德镇</a><a class="isoffline" onclick="selectThis(this.text);">吉安</a><a class="isoffline" onclick="selectThis(this.text);">佳木斯</a><a class="isoffline" onclick="selectThis(this.text);">酒泉</a><a class="isoffline" onclick="selectThis(this.text);">金昌</a><a class="isoffline" onclick="selectThis(this.text);">鸡西</a><a class="isoffline" onclick="selectThis(this.text);">济源</a><a class="isoffline" onclick="selectThis(this.text);">晋城</a><a class="isoffline" onclick="selectThis(this.text);">揭阳</a><a class="isoffline" onclick="selectThis(this.text);">晋中</a><a class="isoffline" onclick="selectThis(this.text);">荆门</a><a class="isoffline" onclick="selectThis(this.text);">九江</a></span></p>
                  </li>
                  <li id="city-K">
                    <p class="cf"><span class="label"><strong>K</strong></span><span><a class="isonline" onclick="selectThis(this.text);">昆明</a><a class="isonline" onclick="selectThis(this.text);">昆山</a><a class="isoffline" onclick="selectThis(this.text);">喀什</a><a class="isoffline" onclick="selectThis(this.text);">克拉玛依</a><a class="isoffline" onclick="selectThis(this.text);">开封</a><a class="isoffline" onclick="selectThis(this.text);">克州</a></span></p>
                  </li>
                  <li id="city-L">
                    <p class="cf"><span class="label"><strong>L</strong></span><span><a class="isonline" onclick="selectThis(this.text);">兰州</a><a class="isonline" onclick="selectThis(this.text);">临沂</a><a class="isonline" onclick="selectThis(this.text);">连云港</a><a class="isonline" onclick="selectThis(this.text);">聊城</a><a class="isonline" onclick="selectThis(this.text);">临汾</a><a class="isonline" onclick="selectThis(this.text);">柳州</a><a class="isonline" onclick="selectThis(this.text);">洛阳</a><a class="isonline" onclick="selectThis(this.text);">廊坊</a><a class="isoffline" onclick="selectThis(this.text);">龙岩</a><a class="isoffline" onclick="selectThis(this.text);">六盘水</a><a class="isoffline" onclick="selectThis(this.text);">凉山</a><a class="isoffline" onclick="selectThis(this.text);">六安</a><a class="isoffline" onclick="selectThis(this.text);">丽江</a><a class="isoffline" onclick="selectThis(this.text);">临沧</a><a class="isoffline" onclick="selectThis(this.text);">陇南</a><a class="isoffline" onclick="selectThis(this.text);">拉萨</a><a class="isoffline" onclick="selectThis(this.text);">辽源</a><a class="isoffline" onclick="selectThis(this.text);">辽阳</a><a class="isoffline" onclick="selectThis(this.text);">莱芜</a><a class="isoffline" onclick="selectThis(this.text);">漯河</a><a class="isoffline" onclick="selectThis(this.text);">吕梁</a><a class="isoffline" onclick="selectThis(this.text);">丽水</a><a class="isoffline" onclick="selectThis(this.text);">临夏</a><a class="isoffline" onclick="selectThis(this.text);">林芝</a><a class="isoffline" onclick="selectThis(this.text);">娄底</a><a class="isoffline" onclick="selectThis(this.text);">来宾</a><a class="isoffline" onclick="selectThis(this.text);">泸州</a><a class="isoffline" onclick="selectThis(this.text);">乐山</a></span></p>
                  </li>
                  <li id="city-M">
                    <p class="cf"><span class="label"><strong>M</strong></span><span><a class="isoffline" onclick="selectThis(this.text);">马鞍山</a><a class="isoffline" onclick="selectThis(this.text);">绵阳</a><a class="isoffline" onclick="selectThis(this.text);">茂名</a><a class="isoffline" onclick="selectThis(this.text);">牡丹江</a><a class="isoffline" onclick="selectThis(this.text);">梅州</a><a class="isoffline" onclick="selectThis(this.text);">眉山</a></span></p>
                  </li>
                  <li id="city-N">
                    <p class="cf"><span class="label"><strong>N</strong></span><span><a class="isonline" onclick="selectThis(this.text);">南京</a><a class="isonline" onclick="selectThis(this.text);">宁波</a><a class="isonline" onclick="selectThis(this.text);">南通</a><a class="isonline" onclick="selectThis(this.text);">南宁</a><a class="isonline" onclick="selectThis(this.text);">南昌</a><a class="isoffline" onclick="selectThis(this.text);">南充</a><a class="isoffline" onclick="selectThis(this.text);">宁德</a><a class="isoffline" onclick="selectThis(this.text);">内江</a><a class="isoffline" onclick="selectThis(this.text);">怒江</a><a class="isoffline" onclick="selectThis(this.text);">南平</a><a class="isoffline" onclick="selectThis(this.text);">南阳</a><a class="isoffline" onclick="selectThis(this.text);">那曲</a></span></p>
                  </li>
                  <li id="city-P">
                    <p class="cf"><span class="label"><strong>P</strong></span><span><a class="isoffline" onclick="selectThis(this.text);">萍乡</a><a class="isoffline" onclick="selectThis(this.text);">平顶山</a><a class="isoffline" onclick="selectThis(this.text);">莆田</a><a class="isoffline" onclick="selectThis(this.text);">濮阳</a><a class="isoffline" onclick="selectThis(this.text);">攀枝花</a><a class="isoffline" onclick="selectThis(this.text);">平凉</a><a class="isoffline" onclick="selectThis(this.text);">普洱</a><a class="isoffline" onclick="selectThis(this.text);">盘锦</a></span></p>
                  </li>
                  <li id="city-Q">
                    <p class="cf"><span class="label"><strong>Q</strong></span><span><a class="isonline" onclick="selectThis(this.text);">青岛</a><a class="isonline" onclick="selectThis(this.text);">泉州</a><a class="isonline" onclick="selectThis(this.text);">秦皇岛</a><a class="isonline" onclick="selectThis(this.text);">齐齐哈尔</a><a class="isoffline" onclick="selectThis(this.text);">庆阳</a><a class="isoffline" onclick="selectThis(this.text);">衢州</a><a class="isoffline" onclick="selectThis(this.text);">黔西南</a><a class="isoffline" onclick="selectThis(this.text);">钦州</a><a class="isoffline" onclick="selectThis(this.text);">黔南</a><a class="isoffline" onclick="selectThis(this.text);">曲靖</a><a class="isoffline" onclick="selectThis(this.text);">黔东南</a><a class="isoffline" onclick="selectThis(this.text);">七台河</a><a class="isoffline" onclick="selectThis(this.text);">清远</a></span></p>
                  </li>
                  <li id="city-R">
                    <p class="cf"><span class="label"><strong>R</strong></span><span><a class="isoffline" onclick="selectThis(this.text);">日照</a><a class="isoffline" onclick="selectThis(this.text);">日喀则</a></span></p>
                  </li>
                  <li id="city-S">
                    <p class="cf"><span class="label"><strong>S</strong></span><span><a class="isonline" onclick="selectThis(this.text);">上海</a><a class="isonline" onclick="selectThis(this.text);">深圳</a><a class="isonline" onclick="selectThis(this.text);">沈阳</a><a class="isonline" onclick="selectThis(this.text);">苏州</a><a class="isonline" onclick="selectThis(this.text);">石家庄</a><a class="isonline" onclick="selectThis(this.text);">绍兴</a><a class="isonline" onclick="selectThis(this.text);">顺德</a><a class="isonline" onclick="selectThis(this.text);">三亚</a><a class="isoffline" onclick="selectThis(this.text);">韶关</a><a class="isoffline" onclick="selectThis(this.text);">绥化</a><a class="isoffline" onclick="selectThis(this.text);">松原</a><a class="isoffline" onclick="selectThis(this.text);">上饶</a><a class="isoffline" onclick="selectThis(this.text);">十堰</a><a class="isoffline" onclick="selectThis(this.text);">三门峡</a><a class="isoffline" onclick="selectThis(this.text);">山南</a><a class="isoffline" onclick="selectThis(this.text);">邵阳</a><a class="isoffline" onclick="selectThis(this.text);">遂宁</a><a class="isoffline" onclick="selectThis(this.text);">商丘</a><a class="isoffline" onclick="selectThis(this.text);">朔州</a><a class="isoffline" onclick="selectThis(this.text);">随州</a><a class="isoffline" onclick="selectThis(this.text);">汕尾</a><a class="isoffline" onclick="selectThis(this.text);">四平</a><a class="isoffline" onclick="selectThis(this.text);">三峡</a><a class="isoffline" onclick="selectThis(this.text);">宿迁</a><a class="isoffline" onclick="selectThis(this.text);">三明</a><a class="isoffline" onclick="selectThis(this.text);">石嘴山</a><a class="isoffline" onclick="selectThis(this.text);">双鸭山</a><a class="isoffline" onclick="selectThis(this.text);">汕头</a><a class="isoffline" onclick="selectThis(this.text);">宿州</a><a class="isoffline" onclick="selectThis(this.text);">商洛</a></span></p>
                  </li>
                  <li id="city-T">
                    <p class="cf"><span class="label"><strong>T</strong></span><span><a class="isonline" onclick="selectThis(this.text);">天津</a><a class="isonline" onclick="selectThis(this.text);">太原</a><a class="isonline" onclick="selectThis(this.text);">泰安</a><a class="isonline" onclick="selectThis(this.text);">台州</a><a class="isonline" onclick="selectThis(this.text);">唐山</a><a class="isonline" onclick="selectThis(this.text);">泰州</a><a class="isoffline" onclick="selectThis(this.text);">塔城</a><a class="isoffline" onclick="selectThis(this.text);">铜陵</a><a class="isoffline" onclick="selectThis(this.text);">铜川</a><a class="isoffline" onclick="selectThis(this.text);">台北</a><a class="isoffline" onclick="selectThis(this.text);">铜仁</a><a class="isoffline" onclick="selectThis(this.text);">吐鲁番</a><a class="isoffline" onclick="selectThis(this.text);">天水</a><a class="isoffline" onclick="selectThis(this.text);">通辽</a><a class="isoffline" onclick="selectThis(this.text);">铁岭</a><a class="isoffline" onclick="selectThis(this.text);">通化</a></span></p>
                  </li>
                  <li id="city-W">
                    <p class="cf"><span class="label"><strong>W</strong></span><span><a class="isonline" onclick="selectThis(this.text);">武汉</a><a class="isonline" onclick="selectThis(this.text);">无锡</a><a class="isonline" onclick="selectThis(this.text);">温州</a><a class="isonline" onclick="selectThis(this.text);">芜湖</a><a class="isonline" onclick="selectThis(this.text);">威海</a><a class="isonline" onclick="selectThis(this.text);">潍坊</a><a class="isoffline" onclick="selectThis(this.text);">乌鲁木齐</a><a class="isoffline" onclick="selectThis(this.text);">梧州</a><a class="isoffline" onclick="selectThis(this.text);">吴忠</a><a class="isoffline" onclick="selectThis(this.text);">武威</a><a class="isoffline" onclick="selectThis(this.text);">渭南</a><a class="isoffline" onclick="selectThis(this.text);">乌兰察布</a><a class="isoffline" onclick="selectThis(this.text);">文山</a><a class="isoffline" onclick="selectThis(this.text);">乌海</a></span></p>
                  </li>
                  <li id="city-X">
                    <p class="cf"><span class="label"><strong>X</strong></span><span><a class="isonline" onclick="selectThis(this.text);">西安</a><a class="isonline" onclick="selectThis(this.text);">厦门</a><a class="isonline" onclick="selectThis(this.text);">徐州</a><a class="isonline" onclick="selectThis(this.text);">襄阳</a><a class="isonline" onclick="selectThis(this.text);">西宁</a><a class="isoffline" onclick="selectThis(this.text);">孝感</a><a class="isoffline" onclick="selectThis(this.text);">西双版纳</a><a class="isoffline" onclick="selectThis(this.text);">新余</a><a class="isoffline" onclick="selectThis(this.text);">湘潭</a><a class="isoffline" onclick="selectThis(this.text);">锡林郭勒</a><a class="isoffline" onclick="selectThis(this.text);">兴安</a><a class="isoffline" onclick="selectThis(this.text);">邢台</a><a class="isoffline" onclick="selectThis(this.text);">新乡</a><a class="isoffline" onclick="selectThis(this.text);">湘西</a><a class="isoffline" onclick="selectThis(this.text);">忻州</a><a class="isoffline" onclick="selectThis(this.text);">咸阳</a><a class="isoffline" onclick="selectThis(this.text);">宣城</a><a class="isoffline" onclick="selectThis(this.text);">香港</a><a class="isoffline" onclick="selectThis(this.text);">信阳</a><a class="isoffline" onclick="selectThis(this.text);">咸宁</a><a class="isoffline" onclick="selectThis(this.text);">许昌</a></span></p>
                  </li>
                  <li id="city-Y">
                    <p class="cf"><span class="label"><strong>Y</strong></span><span><a class="isonline" onclick="selectThis(this.text);">扬州</a><a class="isonline" onclick="selectThis(this.text);">烟台</a><a class="isonline" onclick="selectThis(this.text);">盐城</a><a class="isonline" onclick="selectThis(this.text);">运城</a><a class="isonline" onclick="selectThis(this.text);">义乌</a><a class="isonline" onclick="selectThis(this.text);">岳阳</a><a class="isonline" onclick="selectThis(this.text);">宜昌</a><a class="isoffline" onclick="selectThis(this.text);">玉林</a><a class="isoffline" onclick="selectThis(this.text);">银川</a><a class="isoffline" onclick="selectThis(this.text);">鹰潭</a><a class="isoffline" onclick="selectThis(this.text);">雅安</a><a class="isoffline" onclick="selectThis(this.text);">伊犁</a><a class="isoffline" onclick="selectThis(this.text);">玉树</a><a class="isoffline" onclick="selectThis(this.text);">宜春</a><a class="isoffline" onclick="selectThis(this.text);">营口</a><a class="isoffline" onclick="selectThis(this.text);">永州</a><a class="isoffline" onclick="selectThis(this.text);">宜宾</a><a class="isoffline" onclick="selectThis(this.text);">益阳</a><a class="isoffline" onclick="selectThis(this.text);">玉溪</a><a class="isoffline" onclick="selectThis(this.text);">阳泉</a><a class="isoffline" onclick="selectThis(this.text);">延安</a><a class="isoffline" onclick="selectThis(this.text);">榆林</a><a class="isoffline" onclick="selectThis(this.text);">云浮</a><a class="isoffline" onclick="selectThis(this.text);">延边</a><a class="isoffline" onclick="selectThis(this.text);">阳江</a><a class="isoffline" onclick="selectThis(this.text);">伊春</a></span></p>
                  </li>
                  <li id="city-Z">
                    <p class="cf"><span class="label"><strong>Z</strong></span><span><a class="isonline" onclick="selectThis(this.text);">郑州</a><a class="isonline" onclick="selectThis(this.text);">镇江</a><a class="isonline" onclick="selectThis(this.text);">中山</a><a class="isonline" onclick="selectThis(this.text);">淄博</a><a class="isonline" onclick="selectThis(this.text);">珠海</a><a class="isonline" onclick="selectThis(this.text);">遵义</a><a class="isoffline" onclick="selectThis(this.text);">株洲</a><a class="isoffline" onclick="selectThis(this.text);">自贡</a><a class="isoffline" onclick="selectThis(this.text);">舟山</a><a class="isoffline" onclick="selectThis(this.text);">湛江</a><a class="isoffline" onclick="selectThis(this.text);">肇庆</a><a class="isoffline" onclick="selectThis(this.text);">漳州</a><a class="isoffline" onclick="selectThis(this.text);">张掖</a><a class="isoffline" onclick="selectThis(this.text);">昭通</a><a class="isoffline" onclick="selectThis(this.text);">张家界</a><a class="isoffline" onclick="selectThis(this.text);">周口</a><a class="isoffline" onclick="selectThis(this.text);">驻马店</a><a class="isoffline" onclick="selectThis(this.text);">张家口</a><a class="isoffline" onclick="selectThis(this.text);">资阳</a><a class="isoffline" onclick="selectThis(this.text);">中卫</a><a class="isoffline" onclick="selectThis(this.text);">枣庄</a></span></p>
                  </li>
                </ol>
              </div>
            </div>
          </div>
          <!-- bd end -->
        </div>
        <!-- bdw end -->
      </div>
      </div>
      <script language="javascript" type="text/javascript">
      function selectThis(value){
          var str = $("#selectarea_str").val();
          //var dia = $("#selectarea_dialog").val();
          if(value){
              $("#"+str).val(value);
              $(#tocitySelectDialog).dialog(close);
          }else{ $.messager.alert(提示信息,"请选择地区!");
          }
      }
      $(function (){
          $(".hasallcity li").hover(function(){
              $(this).addClass(hover);
          }, function(){
              $(this).removeClass(hover);
          });    
      });
      </script>
      选择城市
  • Javascript中的undefined、null、""、0值和false的区别总结

    • 技术分享
      在程序语言中定义的各种各样的数据类型中,我们都会为其定义一个"空值"或"假值",比如对象类型的空值null,.NET Framework中数据库字段的空值DBNull,boolean类型的假值false等等。在JavaScript中也有很多种的"空值"和"假值",那么它们都有什么共同点和不同点呢? 
      
      
          其实标题里面我已经列出了JavaScript中所有的"空值"和"假值",除了boolean值本身就是true和false这两种情况外,其它数据类型的"空值"主要是undefined和defined这两大类。这些空值的类型分别是: 
      
      typeof(undefined) == ‘undefined‘ 
      typeof(null) == ‘object‘ 
      typeof("") == ‘string‘ 
      typeof(0) == ‘number‘ 
      typeof(false) == ‘boolean‘ 
      
       
      
         这五个值的共同点是,在if语句中做判断,都会执行false分支。当然从广义上来看,是说明这些数值都是其对应数据类型上的无效值或空值。还有这五个值作!运算,结果全为:true。 
      
          这几个值中也有不同,其中undefined和null比较特殊,虽然null的类型是object,但是null不具有任何对象的特性,就是说我们并不能执行null.toString()、null.constructor等对象实例的默认调用。所以从这个意义上来说,null和undefined有最大的相似性。看看null == undefined的结果(true)也就更加能说明这点。不过相似归相似,还是有区别的,就是和数字运算时,10 + null结果为:10;10 + undefined结果为:NaN。 
      
          另外""、0和false虽然在if语句表现为"假值",可它们都是有意义数据,只是被作为了"空值"或"假值",因为:"".toString(),(0).toString()和false.toString()都是合法的可执行表达式。 
      
          其实这5个值在上面所说的这些差异里,并不太会给程流程控制带来太大的问题,那么要区分它们什么呢?需要注意区分的是这些值在转换为String时的差异是比较大的,它们到String的转换关系是: 
      
      String(undefined) -> "undefined" 
      String(null) -> "null" 
      String("") -> "" 
      String(0) -> "0" 
      String(false) -> "false" 
      
          这个转换关系在做字符串累加时需要特别的注意,否这会出些意想不到的问题,今天就遇到一个null被默认转为"null"给弄得迷糊了好一阵子
      Javascript中的undefined、null、""、0值和false的区别总结
  • 检测密码强度

    • 技术分享
      /**
                * 检测密码强度
                * 返回值
                * 0 长度错误
                * 1 弱
                * 2 中
                * 3 强
                */
               function passwordCheck(value){
                   //长度 6-16
                   if(value.length<6 || value.length>16){
                       return 0;//长度错误
                   }
      
                   var length = value.length;
                   var upper_len = length - value.replace(/[A-Z]/g, ‘‘).length;
                   var lower_len = length - value.replace(/[a-z]/g, ‘‘).length;
                   var num_len = length - value.replace(/\d/g, ‘‘).length;
                   var other_len = length - value.replace(/[^0-9a-zA-Z]/g, ‘‘).length;
      
                   var score = 0;
      
                   //长度
                   if(length<7){
                       score+=5;
                   }else if(length<9){
                       score+=20
                   }else{
                       score+=30;
                   }
      
                   //包含大小写字母
                   if(upper_len==0 && lower_len==0){//
                       score+=0;
                   }else if(upper_len==0 || lower_len==0){//只有一种
                       score+=10;
                   }else{//都包含
                       score+=20;
                   }
      
                   //数字
                   if(num_len==0){//
                       score+=0;
                   }else if(num_len<3){//1-2
                       score+=10;
                   }else{//大于2
                       score+=20;
                   }
      
                   //字符
                   if(other_len==0){//
                       score+=0;
                   }else if(other_len<2){//1
                       score+=10;
                   }else{//大于1
                       score+=20;
                   }
      
                   //综合
                   if(other_len>0 && num_len>0 && upper_len>0 && lower_len>0){//包含大小写字母,数字,符号
                       score+=30;
                   }else if(other_len>0 && num_len>0 && upper_len+lower_len>0){//只包含数字,符号,大写或小写字母
                       score+=20;
                   }else if(other_len==0 && num_len>0 && upper_len+lower_len>0){//只包含数字,字母
                       score+=10;
                   }
      
                   //分数范围15-95
                   if(score<50){
                       score = 1;//
                   }else if(score<70){
                       score = 2;//
                   }else{
                       score = 3;//
                   }
                   return score;
               };
      检测密码强度

 

  • Jquery校验注册页面  jsp

    • 技术分享
      <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
      <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
      <link href="../css/wysi/bootstrap-wysihtml5.css" rel="stylesheet">
      <link href="../css/jquery.filer.css" rel="stylesheet">
      <link rel="shortcut icon" href="../img/favicon.ico?id=1">
      <style>
      .form-control {
          width: 200px;
          display: inline-block;
      }
      </style>
      <div class="fmt">
          <form id="addRegisterForm" class="form-horizontal no-margin" action="register/province">
              <input type="hidden" class="form-control" name="kind" value="${kind}">
      
              <table class="table-form">
                  <tr>
                      <td>登录名:<span class="color-red">*</span></td>
                      <td id="login" class="text-left"><input type="text" id="loginId" class="form-control" name="loginId" placeholder="登录名" value="" required /></td>
                  </tr>
                  <tr>
                      <td>登录密码:<span class="color-red">*</span></td>
                      <td class="text-left"><input type="password" id="password" class="form-control" name="password" placeholder="登录密码" value="" required autocomplete=‘off‘>
                          <span id="password_sp"> </span>
                      </td>
                  </tr>
                  <tr>
                      <td>重复密码:<span class="color-red">*</span></td>
                      <td class="text-left"><input type="password" id="password_again" class="form-control" name="password_again" placeholder="重复密码" value="" required autocomplete=‘off‘></td>
                  </tr>
                  <tr>
                      <td>公司名:<span class="color-red">*</span></td>
                      <td class="text-left"><input type="text" id="name" name="name" class="form-control" placeholder="公司名" value="" required></td>
                  </tr>
                  <c:if test="${kind!=4}">
                      <tr>
                          <td>所属地区:<span class="color-red">*</span></td>
                          <td class="text-left"><input id="dept_id" class="form-control" type="hidden" name="dept" value="" required> <input id="dept_name" class="form-control" name="areaName" value="" onclick="loadUserAreaTree();" placeholder="所属地区" required>
                              <div id="UserAreaTree" class="ztree featured-articles-container" style="width: 182px; height: 300px\9; max-height: 300px; z-index: 100; display: none; position: absolute; overflow: auto;"></div></td>
                      </tr>
                  </c:if>
                  <tr>
                      <td>联系人:<span class="color-red">*</span></td>
                      <td class="text-left"><input type="text" id="userContacts" class="form-control" name="userContacts" placeholder="联系人" value="" required></td>
                  </tr>
                  <tr>
                      <td>手机号码:<span class="color-red">*</span></td>
                      <td class="text-left"><input type="text" id="tel" class="form-control" name="tel" placeholder="手机号码" value="" required></td>
                  </tr>
                  <tr>
                      <td>验证码:<span class="color-red">*</span></td>
                      <td class="text-left"><input id="code" name="code" class="form-control" type="text" autocomplete="off" placeholder="验证码" required> <img id="codeImg" alt="点击更换" title="点击更换" src="../code?t=123" class="m"></td>
                  </tr>
                  <tr>
                      <td colspan="8"><input type="button" value="保存" class="btn btn-info w-200 mr-100" onclick="save();" /> <input type="button" value="取消" class="btn btn-info w-200" onclick="currentTabLoadURL(‘../login‘);" /></td>
                  </tr>
              </table>
          </form>
      </div>
      <script type="text/javascript">    
          function save() {
              $("#addRegisterForm").submit();
          }
          $(function() {
              $(:input).bind(keyup mouseup, function(){
                    $(this).val( $.trim($(this).val()));
              });
              $("#password").blur(function(){ //鼠标离开文本框时触发
                  var value = $(this).val();
                  var re=passwordCheck(value);
                  $("#password_sp").html("");
                  if(re==1){
                      $("#password_sp").html("<span style=‘color:orange‘>密码强度弱</span>");
                  }else if(re==2){
                      $("#password_sp").html("<span style=‘color:blue‘>密码强度中</span>");
                  }else if(re==3){
                      $("#password_sp").html("<span style=‘color:green‘>密码强度强</span>");
                  }
               });
               /**
                * 检测密码强度
                * 返回值
                * 0 长度错误
                * 1 弱
                * 2 中
                * 3 强
                */
               function passwordCheck(value){
                   //长度 6-16
                   if(value.length<6 || value.length>16){
                       return 0;//长度错误
                   }
      
                   var length = value.length;
                   var upper_len = length - value.replace(/[A-Z]/g, ‘‘).length;
                   var lower_len = length - value.replace(/[a-z]/g, ‘‘).length;
                   var num_len = length - value.replace(/\d/g, ‘‘).length;
                   var other_len = length - value.replace(/[^0-9a-zA-Z]/g, ‘‘).length;
      
                   var score = 0;
      
                   //长度
                   if(length<7){
                       score+=5;
                   }else if(length<9){
                       score+=20
                   }else{
                       score+=30;
                   }
      
                   //包含大小写字母
                   if(upper_len==0 && lower_len==0){//
                       score+=0;
                   }else if(upper_len==0 || lower_len==0){//只有一种
                       score+=10;
                   }else{//都包含
                       score+=20;
                   }
      
                   //数字
                   if(num_len==0){//
                       score+=0;
                   }else if(num_len<3){//1-2
                       score+=10;
                   }else{//大于2
                       score+=20;
                   }
      
                   //字符
                   if(other_len==0){//
                       score+=0;
                   }else if(other_len<2){//1
                       score+=10;
                   }else{//大于1
                       score+=20;
                   }
      
                   //综合
                   if(other_len>0 && num_len>0 && upper_len>0 && lower_len>0){//包含大小写字母,数字,符号
                       score+=30;
                   }else if(other_len>0 && num_len>0 && upper_len+lower_len>0){//只包含数字,符号,大写或小写字母
                       score+=20;
                   }else if(other_len==0 && num_len>0 && upper_len+lower_len>0){//只包含数字,字母
                       score+=10;
                   }
      
                   //分数范围15-95
                   if(score<50){
                       score = 1;//
                   }else if(score<70){
                       score = 2;//
                   }else{
                       score = 3;//
                   }
                   return score;
               };
              
              //提交的验证
              $("#addRegisterForm").validate({
                  
                   //出错时添加的标签
                  errorElement: "span",
                  rules: {
                      loginId: {
                          required: true,
                          minlength: 6,
                          maxlength: 16,
                          remote: {
                              type: "post",
                              url: "register/checkRepeat",
                              data: {
                                  username: function() {
                                      return $("#loginId").val();
                                  }
                              },
                              dataFilter: function(data, type) {
                                  if (data == "true"){
                                      return false;
                                  }else{
                                      return true;
                                  }
                                    
                              }
                          }
                      },
                      name: {
                          required: true,
                          minlength: 6,
                          maxlength: 16,
                          remote: {
                              type: "post",
                              url: "register/checkName",
                              data: {
                                  username: function() {
                                      return $("#name").val();
                                  }
                              },
                              dataFilter: function(data, type) {
                                  if (data == "true"){
                                      return false;
                                  }else{
                                      return true;
                                  }
                                    
                              }
                          }
                      },
                      tel: {
                          required : true,
                          //minlength : 11,
                          // 自定义方法:校验手机号在数据库中是否存在
                          phone : true
                      },
                     
                        password: {
                          required : true,
                          minlength : 6,
                          maxlength: 16,
                          // 自定义方法:校验手机号在数据库中是否存在
                       },   
                      password_again: {
                        equalTo: "#password"
                      }
                  },
                  success: function(label) {
                      //正确时的样式
                      label.text(" ").addClass("success");
                  },
                  messages: {
                      loginId: {
                          required: "请输入用户名",
                          minlength: "用户名长度不能小于6个字符",
                          maxlength: "用户名长度不能大于16个字符",
                          remote: "用户名已存在"
                      },
                      name: {
                      required: "请输入公司名称",
                      minlength: "公司名称长度不能小于6个字",
                      maxlength: "公司名称长度不能大于30个字",
                      remote: "公司名称已存在"
                  }
                  },          
                  submitHandler:function(form){ 
                      $(form).ajaxSubmit({
                          type : "post", //提交方式  
                          dataType : "json", //数据类型  
                          contentType : "application/x-www-form-urlencoded; charset=utf-8",
                          success:function(data){
                              if(data ==true){
                                  alert("注册成功,请登录临时用户,完善公司信息,并打印申请表")
                                  location.href="/ers/login";
                              }else{
                                  popWarning("保存失败");
                              }
                              return false;
                          },
                          error:function(xhr,status,error){
                              popWarning("提交失败");
                          }
                      });
                      return false;
                  }
              });
               $("#codeImg").bind("click", refreshRandomCode);
          });
          function refreshRandomCode() {
              $("#codeImg").attr("src", "../code?t=" + new Date().getTime());
          }
          function loadUserAreaTree(){
              loadAreaTree("UserAreaTree",function(nodeId,nodeName){
                  $("#dept_id").val(nodeId);
                  $("#dept_name").val(nodeName);
              },false);
          }
          
          </script>
      View Code

       

js小技巧

标签:color   也有   turn   encoding   tar   change   exe   doctype   round   

原文地址:http://www.cnblogs.com/gcjava/p/6800707.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!