Created
April 13, 2016 15:02
-
-
Save heriipurnama/3c53173907471b8ccf35d3a30b8108b5 to your computer and use it in GitHub Desktop.
find-service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Search Box Example 1</title> | |
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> | |
<!-- CSS styles for standard search box --> | |
<style type="text/css"> | |
#tfheader{ | |
background-color:#c3dfef; | |
} | |
#tfnewsearch{ | |
float:right; | |
padding:20px; | |
} | |
.tftextinput{ | |
margin: 0; | |
padding: 5px 15px; | |
font-family: Arial, Helvetica, sans-serif; | |
font-size:14px; | |
border:1px solid #0076a3; border-right:0px; | |
border-top-left-radius: 5px 5px; | |
border-bottom-left-radius: 5px 5px; | |
} | |
.tfbutton { | |
margin: 0; | |
padding: 5px 15px; | |
font-family: Arial, Helvetica, sans-serif; | |
font-size:14px; | |
outline: none; | |
cursor: pointer; | |
text-align: center; | |
text-decoration: none; | |
color: #ffffff; | |
border: solid 1px #0076a3; border-right:0px; | |
background: #0095cd; | |
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5)); | |
background: -moz-linear-gradient(top, #00adee, #0078a5); | |
border-top-right-radius: 5px 5px; | |
border-bottom-right-radius: 5px 5px; | |
} | |
.tfbutton:hover { | |
text-decoration: none; | |
background: #007ead; | |
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e)); | |
background: -moz-linear-gradient(top, #0095cc, #00678e); | |
} | |
/* Fixes submit button height problem in Firefox */ | |
.tfbutton::-moz-focus-inner { | |
border: 0; | |
} | |
.tfclear{ | |
clear:both; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- HTML for SEARCH BAR --> | |
<div id="tfheader"> | |
<form id="tfnewsearch" method="get" action="/caris"> | |
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"> | |
<input type="submit" value="search" class="tfbutton"> | |
</form> | |
<div class="tfclear"></div> | |
</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% layout('layout') -%> | |
<p> | |
nanam | |
<p> | |
<% books.forEach(function(user){ %> | |
pages:<%= user.pages %><br> | |
name:<%= user.name %><br> | |
isbn:<%= user.isbn %><br> | |
<% })%> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get('/caris', function(req,res){ | |
var a = {"pages":12}; | |
//if (q) {}; | |
//var q = req.body; | |
console.log(req.body); | |
//console.log(req.body); | |
//var z = {"pages":"q"}; | |
//console.log(req.body); | |
books.find({}, function(err, books){ | |
res.render('cari.ejs',{books:books}); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bagaimanakah atau scrip untuk mengambil value dari nilai yang telah dimasukkan klient dari web, lemudian ditangkap oleh express lalu diambil yang dijadikan nilai value yang digunkan untuk mencari record dalam mongoDb,
kalau pencarian menggunakan contoh find({"s":"j"})
memang bisa, lalu bagaimnakan cara nilai dalam pencarian tersebut dibuat dinamis sesuai dengan permintaan pada web client..
saya sdh cari di monggos.js sama expres.js tp blm ketemu mngkin ada petunjuk..
saya sdh menyertakan gmbarnya pak
untuk tampilan saya menggunakan ejs.
keterangan
untuk SS sudah disertakan pada bagian atas.
1.pict 1 adalah bila menuliskan apa yang dicari dalam langsung ke script express
2.pict 2 hasil yang ditampilkan
3.pict 3 bagaimanakah mengambil value yang dimasukkan dalam web client atau req client
4.pict 4 script dalam express pada waktu pecarian berdasarkan yang direq client atau dalam menggambil value client
5.pict 5 tampilan setelah yang dicari ada dalam db menggunakan template ejs