jquery datepicker  를 사용하는 영문으로 나오는 경우가 많다..

그래서 한글로 하는 스크립트이다.


$.datepicker.regional['ko']= {
  closeText:'닫기',
  prevText:'이전달',
  nextText:'다음달',
  currentText:'오늘',
  monthNames:['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUM)','7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
  monthNamesShort:['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
  dayNames:['일','월','화','수','목','금','토'],
  dayNamesShort:['일','월','화','수','목','금','토'],
  dayNamesMin:['일','월','화','수','목','금','토'],
  weekHeader:'Wk',
  dateFormat:'yy-mm-dd',
  firstDay:0,
  isRTL:false,
  showMonthAfterYear:true,
  yearSuffix:''
 };
 $.datepicker.setDefaults($.datepicker.regional['ko']); 

'SCRIPT > jquery' 카테고리의 다른 글

juqery datepicker 한글  (0) 2011/10/21
모바일 웹 touch 이벤트  (0) 2011/05/19
jquery ajajx(post)  (0) 2010/12/06
jquery 이벤트 걸기  (0) 2010/10/27
jquery 레이어팝업.. 드래그엔 드랍!  (2) 2010/05/29
jqoury 1.5버젼에서 test해보았씁니다.
아이폰4 , 안드로이드 진져  에서 정상 작동 하더군요^^

$('ul.menu li').live('touchstart', function (event) {
               
              
            });
            $('ul.menu li').live('touchend', function (event) {
               
            });
            $('ul.menu li').live('touchmove', function (event) {
               
            });

 이렇식으로 해당 li 태그에 터치 이벤트를 작성해 주면 끝 ..

정말 좋다 jquery ^^ 

'SCRIPT > jquery' 카테고리의 다른 글

juqery datepicker 한글  (0) 2011/10/21
모바일 웹 touch 이벤트  (0) 2011/05/19
jquery ajajx(post)  (0) 2010/12/06
jquery 이벤트 걸기  (0) 2010/10/27
jquery 레이어팝업.. 드래그엔 드랍!  (2) 2010/05/29
$("#sub_pwd").attr("disabled","disabled");

$.post("경로",{
name: encodeURIComponent($("#idname").val()),
email: encodeURIComponent($("#idemail").val())
},function (msg){
alert(msg);
$("#sub_pwd").removeAttr("disabled");
});

jquery에서 ajax를 다양한 형태로 지원한다.. $.ajax(); 이런식으로 get및 post방식 모두 지웒나다.. 하지만 전 긴문구는 싫어해서 직관적인 $.post로 표현하는 방식을 좋아한다.. ㅎㅎ

자 문구를 보시면  $().attr("disabled","disabled");  는 저같은 경우는 서브밋 버튼을 잠시 막아 준것입니다. 마지막 문구 보시면 $().removeAttr("disabled");  는 다시 활성화 시켜준것입니다^^ ㅎㅎ 이런방식이 정 싫으시다면 .hide(), show() 이방식이 있습니다. 이것은 display 속성을 바꾸어 주는것이죠.. 보였다 안보였다.. 

아 잠시 삼천길로 바쪗네요..ㅎㅎ $.post("경로",{
 파라미터들,,,
},function(msg){
콜백함수 alert(msg);
});

참간단하죠잉~ ^^ 그외에 팁이 있다면 encodeURIComponent 문자열을 인코딩하여 던저준다,.. 한글 파라미터를 넘길시 유용하다.. 만약 utf-8구현이면 굳이 필요 없지만..쩝 euckr 로 인코딩 중이시면 반드시 해주시는게 좋습니다. 그럼 euckr php 페이지에서는 
       $name = iconv("utf-8","CP949",rawurldecode($_POST['name']));
$email = iconv("utf-8","CP949",rawurldecode($_POST['email']));

이런식으로 다 디코딩후 iconv인코딩 변환에서 euckr로 할시 깨지더라구요 반드시 cp949로 해야 합니다^^ 

그럼 이만~~

항상 즐거운 하루 되세요^^ 요즘 전 실버라이트에 빠졌습니다^^;ㅎㅎ

'SCRIPT > jquery' 카테고리의 다른 글

juqery datepicker 한글  (0) 2011/10/21
모바일 웹 touch 이벤트  (0) 2011/05/19
jquery ajajx(post)  (0) 2010/12/06
jquery 이벤트 걸기  (0) 2010/10/27
jquery 레이어팝업.. 드래그엔 드랍!  (2) 2010/05/29
$(document).ready(function(){
//이미지 클릭 이벤트
$("#Image6").click(function(){
$("#maltext").val();
$("#maltext").val("/추가/");
});

});

패이지 리드후 함수가 호출된다~

클릭이란 이벤트를 html에서가 아닌 스크립트 단에서 이벤트를 정의해준다..

'SCRIPT > jquery' 카테고리의 다른 글

juqery datepicker 한글  (0) 2011/10/21
모바일 웹 touch 이벤트  (0) 2011/05/19
jquery ajajx(post)  (0) 2010/12/06
jquery 이벤트 걸기  (0) 2010/10/27
jquery 레이어팝업.. 드래그엔 드랍!  (2) 2010/05/29
//창포커싱 하기
var objDiv = document.getElementById("listchang");
objDiv.scrollTop = objDiv.scrollHeight;

ㅋㅋㅋ 간단하다.. 그냥 해당 div창의 스크롤 높이를 가져와서 

탑으로부터 내려오는 값을 넣어주면 맨아래로 스크롤이 포커싱! ㅋㅋ
모바일 과 웹페이지를 분기 해주는 스크립트이다..

<script type="text/javascript">
if (navigator.userAgent.match(/iPad/) == null && navigator.userAgent.match(/Mobile|Windows CE|Windows Phone|Opera Mini|POLARIS/) != null)
    location.href = "http://" + location.host + "/m" + location.pathname;
</script>

간단하다.. 안드로이드 폰과 아이폰 모두 잡아낸다^^ 

<script language="JavaScript">
//모바일 페이지로 이동. 
var uAgent = navigator.userAgent.toLowerCase();
var mobilePhones = new Array('iphone','ipod','android','blackberry','windows ce',
'nokia','webos','opera mini','sonyericsson','opera mobi','iemobile');
for(var i=0;i<mobilePhones.length;i++)
if(uAgent.indexOf(mobilePhones[i]) != -1)
document.location = "http://"+ location.host +"/m" + location.pathname;
</script>

더욱더 자세하게 잡아낼수 있지만.. 굳이 위의 소스를 사용하는 것을 추천한다!!

복잡하다고 좋은게 아니라 얼마나 간단히 쉽게 처리 하는것이 고수로 가는 지름길이라 생각이 든다 ^^

그럼 이만... 즐프~
GET방식으로 전송시에는 상관없지만 
POST방식으로 전송시 인코딩이 정말 중요하다!!EUC-KR 은 깨진다.. 왜냐하면 UTF-8전송이기 때문이다
아래 예를 우선 보자!!!

 request = new createRequest();  
  var url = "../staff/staff_add_update.php";
  var poststring = "";
  var phonenum = $('hp1').value + "-" + $('hp2').value + "-" + $('hp3').value; //휴대폰번호
  
   
  poststring = "pass1=" + encodeURI($('pwd').value);// utf형식으로 변형
  poststring += "&phonenum=" + encodeURI(phonenum);
  poststring += "&zip1=" + encodeURI($('zip1').value);
  poststring += "&zip2=" + encodeURI($('zip2').value);
  poststring += "&juso1=" + encodeURI($('juso1').value);
  poststring += "&juso2=" + encodeURI($('juso2').value);
  poststring += "&staff_id=" + encodeURI($('staff_id').value);
  
  request.onreadystatechange = returnstaff_update;
  request.open("POST",url,true);
  request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");//헤더값 설정함 
  request.setRequestHeader("ajax", "true");
  request.send(poststring);

보면 해더값을 설정하여 UTF-8전송을 하였다.. 그리고 그전에 encodeURI를 통해 인코딩한다!!
이럼 안깨진다^^ 하지만 POST를 받는 페이지가 만약 EUC-KR이라면??

당연히 깨진다!! 왜냐하면 UTF-8로 보내지 않았는가?ㅎㅎ 그문제는 정말 간단히 해결 할수 있다!!

php 에서는 iconv()라는 함수를 이용하여 간단히 인코딩을 변경 가능 하다^^
사용 법은 ...
iconv("현재 언어","인코딩될 언어",인코딩할 string 또는 변수);

'SCRIPT > AJAX' 카테고리의 다른 글

ajax POST전송시 인코딩 문제!!!!  (0) 2010/05/31

==========================================
calender.js
==========================================


var target; // 호출한 Object의 저장
var stime;
document.write("<div id=minical oncontextmenu='return false' ondragstart='return false' onselectstart='return false' style=\"background:buttonface; margin:5; padding:5;margin-top:2;border-top:1 solid buttonshadow;border-left: 1 solid buttonshadow;border-right: 1 solid buttonshadow;border-bottom:1 solid buttonshadow;width:160;display:none;position: absolute; z-index: 99\"></div>");

function Calendar(obj) {

var now = obj.value.split("-");
var x, y;
target = obj; // Object 저장;

x = (document.layers) ? loc.pageX : event.clientX;
y = (document.layers) ? loc.pageY : event.clientY;

minical.style.pixelTop = y+5;
minical.style.pixelLeft = x-50;
minical.style.display = (minical.style.display == "block") ? "none" : "block";

if (now.length == 3) { // 정확한지 검사
Show_cal(now[0],now[1],now[2]); // 넘어온 값을 년월일로 분리
} else {
now = new Date();
Show_cal(now.getFullYear(), now.getMonth()+1, now.getDate()); // 현재 년/월/일을 설정하여 넘김.
}
}


function doOver() { // 마우스가 칼렌다위에 있으면
var el = window.event.srcElement;
cal_Day = el.title;

if (cal_Day.length > 7) { // 날자 값이 있으면.
el.style.borderTopColor = el.style.borderLeftColor = "buttonhighlight";
el.style.borderRightColor = el.style.borderBottomColor = "buttonshadow";
}
window.clearTimeout(stime); // Clear
}

function doClick() { // 날자를 선택하였을 경우
cal_Day = window.event.srcElement.title;
window.event.srcElement.style.borderColor = "red"; // 테두리 색을 빨간색으로
if (cal_Day.length > 7) { // 날자 값이있으면
target.value=cal_Day // 값 설정
}
minical.style.display='none'; // 화면에서 지움
}

function doOut() {
var el = window.event.fromElement;
cal_Day = el.title;

if (cal_Day.length > 7) {
el.style.borderColor = "white";
}
//stime=window.setTimeout("minical.style.display='none';", 200);
}

function day2(d) { // 2자리 숫자료 변경
var str = new String();
if (parseInt(d) < 10) {
str = "0" + parseInt(d);
} else {
str = "" + parseInt(d);
}
return str;
}

function Show_cal(sYear, sMonth, sDay) {
var Months_day = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31)
var Weekday_name = new Array("일", "월", "화", "수", "목", "금", "토");
var intThisYear = new Number(), intThisMonth = new Number(), intThisDay = new Number();
document.all.minical.innerHTML = "";
datToday = new Date(); // 현재 날자 설정
intThisYear = parseInt(sYear);
intThisMonth = parseInt(sMonth);
intThisDay = parseInt(sDay);
if (intThisYear == 0) intThisYear = datToday.getFullYear(); // 값이 없을 경우
if (intThisMonth == 0) intThisMonth = parseInt(datToday.getMonth())+1; // 월 값은 실제값 보다 -1 한 값이 돼돌려 진다.
if (intThisDay == 0) intThisDay = datToday.getDate();
switch(intThisMonth) {
case 1:
intPrevYear = intThisYear -1;
intPrevMonth = 12;
intNextYear = intThisYear;
intNextMonth = 2;
break;
case 12:
intPrevYear = intThisYear;
intPrevMonth = 11;
intNextYear = intThisYear + 1;
intNextMonth = 1;
break;
default:
intPrevYear = intThisYear;
intPrevMonth = parseInt(intThisMonth) - 1;
intNextYear = intThisYear;
intNextMonth = parseInt(intThisMonth) + 1;
break;
}

NowThisYear = datToday.getFullYear(); // 현재 년
NowThisMonth = datToday.getMonth()+1; // 현재 월
NowThisDay = datToday.getDate(); // 현재 일
datFirstDay = new Date(intThisYear, intThisMonth-1, 1); // 현재 달의 1일로 날자 객체 생성(월은 0부터 11까지의 정수(1월부터 12월))
intFirstWeekday = datFirstDay.getDay(); // 현재 달 1일의 요일을 구함 (0:일요일, 1:월요일)
intSecondWeekday = intFirstWeekday;
intThirdWeekday = intFirstWeekday;
datThisDay = new Date(intThisYear, intThisMonth, intThisDay); // 넘어온 값의 날자 생성
intThisWeekday = datThisDay.getDay(); // 넘어온 날자의 주 요일

varThisWeekday = Weekday_name[intThisWeekday]; // 현재 요일 저장
intPrintDay = 1 // 달의 시작 일자
secondPrintDay = 1
thirdPrintDay = 1
Stop_Flag = 0
if ((intThisYear % 4)==0) { // 4년마다 1번이면 (사로나누어 떨어지면)
if ((intThisYear % 100) == 0) {
if ((intThisYear % 400) == 0) {
Months_day[2] = 29;
}
} else {
Months_day[2] = 29;
}
}
intLastDay = Months_day[intThisMonth]; // 마지막 일자 구함
Stop_flag = 0
Cal_HTML = "<TABLE WIDTH=30% BORDER=0 CELLPADDING=0 CELLSPACING=0 ONMOUSEOVER=doOver(); ONMOUSEOUT=doOut(); STYLE='font-size:8pt;font-family:Tahoma;'>"
+ "<TR ALIGN=CENTER><TD COLSPAN=7 nowrap=nowrap ALIGN=CENTER><SPAN TITLE='이전달' STYLE=cursor:hand; onClick='Show_cal("+intPrevYear+","+intPrevMonth+",1);'><FONT COLOR=Navy>◀</FONT></SPAN> "
+ "<B STYLE=color:red>"+get_Yearinfo(intThisYear,intThisMonth,intThisDay)+"년"+get_Monthinfo(intThisYear,intThisMonth,intThisDay)+"월</B>"
+ " <SPAN TITLE='다음달' STYLE=cursor:hand; onClick='Show_cal("+intNextYear+","+intNextMonth+",1);'><FONT COLOR=Navy>▶</FONT></SPAN></TD></TR>"
+ "<TR ALIGN=CENTER BGCOLOR=ThreedFace STYLE='color:White;font-weight:bold;'><TD>일</TD><TD>월</TD><TD>화</TD><TD>수</TD><TD>목</TD><TD>금</TD><TD>토</TD></TR>";
for (intLoopWeek=1; intLoopWeek < 7; intLoopWeek++) { // 주단위 루프 시작, 최대 6주
Cal_HTML += "<TR ALIGN=RIGHT BGCOLOR=WHITE>"
for (intLoopDay=1; intLoopDay <= 7; intLoopDay++) { // 요일단위 루프 시작, 일요일 부터
if (intThirdWeekday > 0) { // 첫주 시작일이 1보다 크면
Cal_HTML += "<TD onClick=doClick();>";
intThirdWeekday--;
} else {
if (thirdPrintDay > intLastDay) { // 입력 날짝 월말보다 크다면
Cal_HTML += "<TD onClick=doClick();>";
} else { // 입력날짜가 현재월에 해당 되면
Cal_HTML += "<TD onClick=doClick(); title="+intThisYear+"-"+day2(intThisMonth).toString()+"-"+day2(thirdPrintDay).toString()+" STYLE=\"cursor:Hand;border:1px solid white;";
if (intThisYear == NowThisYear && intThisMonth==NowThisMonth && thirdPrintDay==intThisDay) {
Cal_HTML += "background-color:cyan;";
}
switch(intLoopDay) {
case 1: // 일요일이면 빨간 색으로
Cal_HTML += "color:red;"
break;
case 7:
Cal_HTML += "color:blue;"
break;
default:
Cal_HTML += "color:black;"
break;
}
Cal_HTML += "\">"+thirdPrintDay;
}
thirdPrintDay++;
if (thirdPrintDay > intLastDay) { // 만약 날짜 값이 월말 값보다 크면 루프문 탈출
Stop_Flag = 1;
}
}
Cal_HTML += "</TD>";
}
Cal_HTML += "</TR>";
if (Stop_Flag==1) break;
}
Cal_HTML += "</TABLE>";

document.all.minical.innerHTML = Cal_HTML;
}

function get_Yearinfo(year,month,day) { // 년 정보를 콤보 박스로 표시
var min = parseInt(year) - 100;
var max = parseInt(year) + 10;
var i = new Number();
var str = new String();
str = "<SELECT onChange='Show_cal(this.value,"+month+","+day+");' ONMOUSEOVER=doOver();>";
for (i=min; i<=max; i++) {
if (i == parseInt(year)) {
str += "<OPTION VALUE="+i+" selected ONMOUSEOVER=doOver();>"+i+"</OPTION>";
} else {
str += "<OPTION VALUE="+i+" ONMOUSEOVER=doOver();>"+i+"</OPTION>";
}
}
str += "</SELECT>";
return str;
}


function get_Monthinfo(year,month,day) { // 월 정보를 콤보 박스로 표시
var i = new Number();
var str = new String();
str = "<SELECT onChange='Show_cal("+year+",this.value,"+day+");' ONMOUSEOVER=doOver();>";
for (i=1; i<=12; i++) {
if (i == parseInt(month)) {
str += "<OPTION VALUE="+i+" selected ONMOUSEOVER=doOver();>"+i+"</OPTION>";
} else {
str += "<OPTION VALUE="+i+" ONMOUSEOVER=doOver();>"+i+"</OPTION>";
}
}
str += "</SELECT>";
return str;
}
 
=======================================================
//여기까지가 자바 스크립트 코딩이며..
아래는 그냥 onclick하여 호출만 해주면 끝
=======================================================

<tr>
<th class="line-b" style="width:100px;">입사일</th>
<td class="line-b"><input type="text" name="enterday" class="text w120" value='' readonly />
<a onclick="Calendar(document.f.enterday);"><img src="/images/icon_dayview.gif" width="20" height="20" border="0" align="absbottom" /></a> </td>
</tr>

//Calendar() 파라미터 값을 떤저주어야 한다.. 해당 폼 네임값만 던져주면 끝!!

그냥 깔끔한 디자인에... '';옆에 인풋박스에 값을 넣어줌!! 그냥 쓰기 편해요;;ㅎㅎ

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    $("#example").dialog({ autoOpen: false });
    $("#poppop").click( function() {
        $("#example").dialog('open');
    });
  });
  </script>
  
</head>
<body>
  <link rel="stylesheet" href="http://dev.jquery.com/view/tags/ui/latest/themes/flora/flora.all.css" type="text/css" media="screen" title="Flora (Default)">
<script type="text/javascript" src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.dialog.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.resizable.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/tags/ui/latest/ui/ui.draggable.js"></script>


<div id="example" class="flora" title="This is my title">I'm in a dialog!</div>
<input type="button" id="poppop" value="popup" />
</body>
</html>

'SCRIPT > jquery' 카테고리의 다른 글

juqery datepicker 한글  (0) 2011/10/21
모바일 웹 touch 이벤트  (0) 2011/05/19
jquery ajajx(post)  (0) 2010/12/06
jquery 이벤트 걸기  (0) 2010/10/27
jquery 레이어팝업.. 드래그엔 드랍!  (2) 2010/05/29

정말 간단하다... 한줄이다'';

tid=setInterval(member_user,5000);

보면 member_user 이부분은 호출할 함수 이름

5000은 초단위 즉 5초를 의미 한다.. 10000이면 10초겠죠?후훗...

setIntervarl(함수명,시간);