Support
Quality
Security
License
Reuse
kandi has reviewed CloudReader and discovered the below as its top functions. This is intended to give you an instant insight into CloudReader implemented functionality, and help decide if they suit your requirements.
1、基本遵循Google Material Design设计风格。
2、玩安卓和干货集中营内容。
3、MvvM-DataBinding的项目应用。
4、NavigationView搭配DrawerLayout的具体使用。
5、透明状态栏使用与版本适配。
6、高仿网易云音乐歌单详情页。
7、RxBus代替EventBus进行组件之间通讯。
8、ToolBar的全方面使用。
9、Glide加载监听,获取缓存,圆形图片,高斯模糊。
10、水波纹点击效果详细使用与适配。
11、Room的基本使用。
12、基于DataBinding的ViewHolder。
13、基于DataBinding的BaseActivity和BaseFragment。
14、Fragment懒加载模式。
15、SwipeRefreshLayout结合RecyclerView下拉刷新上拉加载。
16、CoordinatorLayout+Behavior实现标题栏渐变和滑动置顶。
License
Copyright (C) 2016 Bin Jing
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
QUESTION
Multiple submit buttons for post in Javascript/Node/EJS
Asked 2022-Mar-30 at 05:16So I'm learning Javascript and one of the things I'm practicing is a model view controller of sorts. Right now I have a form with multiple ejs templates, but only the first one pertains to this question.
The first is Home.ejs
<DOCTYPE html>
<html>
<head>
<title> HomeTitle </title>
<style>
body{background: skyblue;}
</style>
<body>
<p> Welcome Home</p>
<div>
<form id ="redirect" method="POST">
<input type="submit"value="SignIn" >
<input type="submit" value="Exit" >
</form>
</body>
<script>
</script>
</head>
</html>
I also have a router.js that handles as the router file.
// Importing the module
const express=require("express")
var bodyParser=require('body-parser')
// Creating express Router
const router=express.Router()
var jsonParser= bodyParser.json()
var urlencodedParser =bodyParser.urlencoded({extended: false});
// Handling login request
router.get("/",(req,res,next)=>{
res.render('home.ejs')
})
router.post("/", urlencodedParser, function (req,res){
return res.redirect("/login");
})
router.get("/login",(req,res,next)=>{
res.render("profile.ejs")
})
router.post("/login", urlencodedParser, function (req,res){
console.log(req.body)
//res.send(req.body.first)
return res.redirect('/');
})
module.exports=router
In my Home.ejs I have two submit buttons, one for signing in, and one for exiting. At present, pressing either button takes me to the sign in page (profile.ejs) I am rendering (b/c there's only one render destination). Is there a way for me to differentiate which button was pressed in the javscript section so that I can chose which page I want to render. For example pressing the Sign In button would render one ejs template, whereas Exit would go to another template that I would render.
The first router.post is the post function where ideally the solution for differentiating would be since that is where I handle rendering the new page based on the post data.
ANSWER
Answered 2022-Mar-30 at 05:16You can assign a name to your inputs:
<input type="submit" value="SignIn" name="submit">
<input type="submit" value="Exit" name="submit">
Then check the value of submitted input and render/redirect based on that value:
const submit = req.body.submit;
if(submit === "SignIn"){
//Do something
} else if(submit === "Exit"){
//Do Something
} else {
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit