0
獲得選擇從單選按鈕值從HTML我試圖讓從單選按鈕 選擇的值,但是當我選擇的老師仍然是的「學生」如何角的js
HTML文件:
<!DOCTYPE html>
<html ng-app="phase2">
<head>
<title>Sign UP Page</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link href="style.css" rel="stylesheet" />
<script data-semver="1.2.28" src="https://code.angularjs.org/1.2.28/angular.js" data-require="[email protected]"></script>
<script src="https://code.angularjs.org/1.2.28/angular-route.js"></script>
\t <script src="RigesterationController.js"></script>
</head>
<body >
<center>
<p>Enter Your User Name : \t <input type="text" , name="UserName" id ="UName" required /> </p>
<p>Enter Your Email : \t <input type="text" , name="Email" id ="email" required /> </p>
<p>Enter Your Password : \t <input type="password" , name="pass" id ="Pass" required/> </p>
<p>Choose Gender : <br> Male<input type="radio" name="gender" value="m" id="Gender" checked/> Female<input type="radio" name="gender" value="f" id="Gender"/> </p>
<p>Choose User Type :<br> Student<input type="radio" name="UserType" value="s" id="Utype" checked/> Teacher<input type="radio" name="UserType" value="t" id="Utype"/> </p>
<div ng-app="phase2" >
\t <div ng-controller="SignUP">
\t \t <input type="button" name="signup" value="SignUP" ng-click="save()" />
\t </div>
</div>
</center>
</body>
</html>
RigesterationController.js文件:
var app = angular.module("phase2" , [])
app.controller("SignUP" ,function ($scope , $http , srvShareData , $location)
\t \t {
\t \t \t $scope.dataToShare = [];
\t \t \t $scope.save = function() {
\t \t \t \t var email= document.getElementById("email").value;
\t \t \t \t var UName=document.getElementById("UName").value;
\t \t \t \t var Pass=document.getElementById("Pass").value;
\t \t \t \t var gender=document.getElementById("Gender").value;
\t \t \t \t var UserType=document.getElementById("Utype").value;
\t \t \t \t alert(UserType)
\t \t \t \t $http.get('http://localhost:8090/SignUp/'+email+'/'+UName+'/'+Pass+'/'+gender+'/'+UserType)
\t \t \t \t .then(function(response)
\t \t \t \t \t {
\t \t \t \t \t });
\t \t \t \t if (UserType=="t")
\t \t \t \t {
\t \t \t \t window.location.href="http://localhost:8060/TheAngular_Project/TeacherPage.html";
\t \t \t \t }
\t \t \t \t else if (UserType=="s")
\t \t \t \t {
\t \t \t \t window.location.href="http://localhost:8060/TheAngular_Project/StudentPage.html";
\t \t \t \t }
\t \t \t \t }
\t \t });
我總是得到S ^雖然我選擇的老師..如何讓選擇的價值? 由於事先
的document.getElementById( 「郵件」)。價值?使用ng-model的值代替 – Sajeetharan
電子郵件和用戶名和密碼工作成功..單選按鈕問題@Sajeetharan –
@AhmedHassan我建議你先閱讀角度。你做錯了基礎知識 – Sajeetharan