如何解决有没有一种方法可以获取profile.getEmail返回值来填充html表单的输入字段?
因此,基本上我想将profile.getEmail()转换为电子邮件形式的输入或em。 抱歉,问题很愚蠢,但我已经在此问题上浪费了几天。 使用来自表单输入字段的数据,我将在golang服务器上进行插入查询。 因此,实际上我需要来自google acoount的数据来注册和/或登录到服务器。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Index</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="MYCLIENTID">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
<h1>Login</h1>
<form action ="/login_process" method="POST">
<label for="email">Email</label>
<input type = "text" name="email" id="email" placeholder = "email address"></br></br>
<label for="password">Password</label>
<input type= "password" id="password" name="password"> </br></br>
<input type = "submit">
</form>
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<script>
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile();
console.log("ID: " + profile.getId()); // Don't send this directly to your server!
console.log('Full Name: ' + profile.getName());
console.log('Given Name: ' + profile.getGivenName());
console.log('Family Name: ' + profile.getFamilyName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
}
</script>
</br></br></br>
<h1>Signup New User</h1>
<form action ="/signup" method="POST">
<label for="signup_email">Email</label>
<input type = "text" name="signup_email" id="signup_email" placeholder = "email address"></br></br>
<label for="signup_password">Password</label>
<input type= "password" id="signup_password" name="signup_password"></br></br>
<label for="signup_password_confirm">Confirm password</label>
<input type= "password" id="signup_password_confirm" name="signup_password_confirm"> </br></br>
<label for="signup_age">Age</label>
<input type = "text" id="signup_age" name ="signup_age" placeholder = "how old are you?"></br></br>
<label for="signup_gender">Gender</label>
<input type = "text" id="signup_gender" name ="signup_gender"></br></br>
<input type = "submit">
</form>
</body>
</html>
解决方法
已解决, document.getElementById(“ mytext”)。value =“我的值”;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。