먼저 구글 스프레드시트에 목록을 입력합니다.
시트 키를 이용하여 html 형식으로 출력되도록 합니다.
기본 구글스프레드시트 주소에서 키를 가져옵니다.
https://docs.google.com/spreadsheets/d/**1z4p9YlkQxsroWcYKEcjnm1NSZPegfBvXUA5cFxrsg6Y**/edit#gid=0
다음 주소에 키를 입력하여 실행합니다.
https://docs.google.com/spreadsheets/u/0/d/**1z4p9YlkQxsroWcYKEcjnm1NSZPegfBvXUA5cFxrsg6Y**/gviz/tq?tqx=out:html
쿼리언어를 이용해서 주소를 수정해주고 원하는 내용만 출력되도록 합니다.
Select *
Where A = 허명성 and B = 080201
https://docs.google.com/spreadsheets/u/0/d/1z4p9YlkQxsroWcYKEcjnm1NSZPegfBvXUA5cFxrsg6Y/gviz/tq?tqx=out:html&tq=SELECT+*+WHERE+A+=+"허명성"+and+B+=+"080201"
https://docs.google.com/spreadsheets/u/0/d/1z4p9YlkQxsroWcYKEcjnm1NSZPegfBvXUA5cFxrsg6Y/gviz/tq?tqx=out:html&tq=SELECT+*+WHERE+A+LIKE+"허명성"+and+B+=+"080201"
구글 스프레드 시트의 공동작업 이슈를 없애기 위해 웹페이지에서 자바스크립트를 이용하고자 합니다.
4.1. 구글 사이트도구를 이용해서 페이지를 만듭니다.
4.2. 페이지에 삽입을 누르고 소스코드를 입력합니다.
4.3. 소스코드는 다음과 같습니다.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script language=javascript>
function getPost() {
var search = document.frmSubmit.txt1.value;
var search2 = document.frmSubmit.txt2.value;
if (search == '' || search == null || search2 == '' || search2 == null) {
alert(" 값을 입력해주세요 ");
} else {
var url;
url = "<https://docs.google.com/spreadsheets/u/0/d/1z4p9YlkQxsroWcYKEcjnm1NSZPegfBvXUA5cFxrsg6Y/gviz/tq?tqx=out:html&tq=SELECT+*+WHERE+A+=+>'" + search + "'+AND+B+=+'" + search2 + "'";
window.open(url, "", "width=400,height=400,left=600");//1
// location.href = url; //2
}
}
</script>
</head>
<body>
<form name=frmSubmit method="POST">
이름<br>
<input type=text name=txt1>
<p>
생년월일<br>
<input type=text name=txt2>
<p>
<input type=button name=btn1 value="검색" target="_blank" onClick="getPost()">
</form>
</body>
</html>