Ajax 활용 (1) > JAVASCRIPT

본문 바로가기
사이트 내 전체검색


회원로그인

JAVASCRIPT

Ajax 활용 (1)

페이지 정보

작성자 LYJ 작성일10-11-16 21:36 조회4,652회 댓글0건

본문

function getXMLHTTPRequest() {
var request = false;
  try {
  // Firefox, Opera 8.0+, Safari
  request = new XMLHttpRequest();
  }
  catch (err1) {
    // Internet Explorer
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (err2) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (err3) {
        request = false;
      }
    }
  }
  return request
}
var http = getXMLHTTPRequest();
function infoSave(no) {
  var myurl = 'ajax_check.php';
  var idx = no;
  if(idx=="1") {
    var data1 = document.getElementById('mobile1').value;
    var data2 = document.getElementById('mobile2').value;
    var data3 = document.getElementById('email1').value;
    var data4 = document.getElementById('email2').value;
  } else if(idx=="2") {
    var data1 = document.getElementById('mobile12').value;
    var data2 = document.getElementById('mobile22').value;
    var data3 = document.getElementById('email12').value;
    var data4 = document.getElementById('email22').value;
  } else if(idx=="3") {
    var data1 = document.getElementById('mobile13').value;
    var data2 = document.getElementById('mobile23').value;
    var data3 = document.getElementById('email13').value;
    var data4 = document.getElementById('email23').value;
  }
  var para = myurl + "?data1=" + data1 + "&data2=" + data2 + "&data3=" + data3 + "&data4=" + data4 + "&data5=" + idx;
 
  http.open("GET", para, true);
  http.onreadystatechange = useHttpResponse;
  http.send(null);
}
function useHttpResponse() {
  if(http.readyState==4) {
    if(http.status == 200) {
      var timeValue = http.responseText;
      if(timeValue==1) {
        var ugbosoo1 = "<font color='red'>예약접수 정보가 수정되었습니다.</font>";
        document.getElementById('myPageElement1').innerHTML = ugbosoo1;
      } else if(timeValue==2) {
        var ugbosoo2 = "<font color='red'>기업체문의 정보가 수정되었습니다.</font>";
        document.getElementById('myPageElement2').innerHTML = ugbosoo2;
      } else if(timeValue==3) {
        var ugbosoo3 = "<font color='red'>엔젤서비스 정보가 수정되었습니다.</font>";
        document.getElementById('myPageElement3').innerHTML = ugbosoo3;
      }
    }
  }
}

<h4>예약접수 - SMS 및 E-mail 주소</h4>
<?
$adma = table_view("tb_adminInfo","1");
?>
<table border="0" cellpadding="0" cellspacing="5" width="800">
  <tr>
    <td width="180">Mobile 1</td><td width="180">Mobile 2</td><td width="180">E-mail 1</td><td width="180">E-mail 2</td>
  </tr>
  <tr>
    <td><input type="text" name="mobile1" id="mobile1" value="<?=$adma[mobile1]?>"></td>
    <td><input type="text" name="mobile2" id="mobile2" value="<?=$adma[mobile2]?>"></td>
    <td><input type="text" name="email1" id="email1" value="<?=$adma[email1]?>" size="30"></td>
    <td><input type="text" name="email2" id="email2" value="<?=$adma[email2]?>" size="30"></td>
  </tr>
  <tr><td colspan="4" align="left"><font color="blue">휴대폰 번호 입력시 "-" 없이 숫자만 입력하세요.</font></td></tr>
  <tr><td colspan="4" align="right"><img src="/images/admin/common/common_btn_reg.jpg" onClick="infoSave(1);" style="cursor:pointer;"></td></tr>
  <tr><td colspan="4" align="left"><span id="myPageElement1"></span></td></tr>
</table>
<br />
<h4>기업체문의 - SMS 및 E-mail 주소</h4>
<?
$primato = table_view("tb_adminInfo","2");
?>
<table border="0" cellpadding="0" cellspacing="5" width="800">
  <tr>
    <td width="180">Mobile 1</td><td width="180">Mobile 2</td><td width="180">E-mail 1</td><td width="180">E-mail 2</td>
  </tr>
  <tr>
    <td><input type="text" name="mobile12" id="mobile12" value="<?=$primato[mobile1]?>"></td>
    <td><input type="text" name="mobile22" id="mobile22" value="<?=$primato[mobile2]?>"></td>
    <td><input type="text" name="email12" id="email12" value="<?=$primato[email1]?>" size="30"></td>
    <td><input type="text" name="email22" id="email22" value="<?=$primato[email2]?>" size="30"></td>
  </tr>
  <tr><td colspan="4" align="left"><font color="blue">휴대폰 번호 입력시 "-" 없이 숫자만 입력하세요.</font></td></tr>
  <tr><td colspan="4" align="right"><img src="/images/admin/common/common_btn_reg.jpg" onClick="infoSave(2);" style="cursor:pointer;"></td></tr>
  <tr><td colspan="4" align="left"><span id="myPageElement2"></span></td></tr>
</table>
<br />
<h4>엔젤서비스 - SMS 및 E-mail 주소</h4>
<?
$anyfus = table_view("tb_adminInfo","3");
?>
<table border="0" cellpadding="0" cellspacing="5" width="800">
  <tr>
    <td width="180">Mobile 1</td><td width="180">Mobile 2</td><td width="180">E-mail 1</td><td width="180">E-mail 2</td>
  </tr>
  <tr>
    <td><input type="text" name="mobile13" id="mobile13" value="<?=$anyfus[mobile1]?>"></td>
    <td><input type="text" name="mobile23" id="mobile23" value="<?=$anyfus[mobile2]?>"></td>
    <td><input type="text" name="email13" id="email13" value="<?=$anyfus[email1]?>" size="30"></td>
    <td><input type="text" name="email23" id="email23" value="<?=$anyfus[email2]?>" size="30"></td>
  </tr>
  <tr><td colspan="4" align="left"><font color="blue">휴대폰 번호 입력시 "-" 없이 숫자만 입력하세요.</font></td></tr>
  <tr><td colspan="4" align="right"><img src="/images/admin/common/common_btn_reg.jpg" onClick="infoSave(3);" style="cursor:pointer;"></td></tr>
  <tr><td colspan="4" align="left"><span id="myPageElement3"></span></td></tr>
</table>

댓글목록

등록된 댓글이 없습니다.


그누보드5
Copyright © jsp.pe.kr All rights reserved.
상단으로
모바일 버전으로 보기