I am attempting to set the action of a GET method on a forum in JQuery, however the forum is not updating/ the button associated with the form is not sending a GET request. I am unsure as to what I am doing wrong.
Am I doing something wrong in how I am assigning the new action?
Here is my code.
extends layout
block content
script.
var accountType = "";
$( document ).ready(function(){
$(".userDetails").hide();
$(".radio-inline").change(function(){
$(".userDetails").show();
accountType = $(".radio-inline:checked").val();
if(accountType == "Student"){
$(".userDetails").attr("action", "/api/student");
$(".userDetails").attr("method", "GET");
}
else if(accountType == "Instructor"){
$(".userDetails").attr("action", "/api/instructor");
$(".userDetails").attr("method", "GET");
}
else if(accountType == "Admin"){
$(".userDetails").attr("action", "/api/admin");
$(".userDetails").attr("method", "GET");
}
});
$("input").change(function(){
if(accountType == "Student"){
var url = "/api/student/"+ $('#name').val() + "/" + $('#password').val();
console.log(url);
$(".form-signin").attr("action", url);
}
else if(accountType == "Instructor"){}
else if(accountType == "Admin"){}
});
});
h2(class="form-signin-heading")
form.form-signin(method="GET")
h2 Select Account
label.radio-inline Student
input.radio-inline(type="radio" name="type" value="Student")
label.radio-inline Instructor
input.radio-inline(type="radio" name="type" value="Instructor")
label.radio-inline Admin
input.radio-inline(type="radio" name="type" value="Admin")
br
label.sr-only(for="inputUser") Username
input.form-control(type="user" id="name"
placeholder="Username" required autofocus)
label.sr-only(for="inputPassword") Password
input.form-control(type="password" id="password" placeholder="Password" required autofocus)
br
btn.btn-lg.btn-primary.btn-block.btn-default(type="submit") Sign in
br
a(href="/make_account") Not a member?
via Tjoudrey
No comments:
Post a Comment