如何获取当前单击的单选按钮

时间:2015-11-26 11:23:49

标签: python

我正在做一个用于大学的Python项目,我必须建立一个用户登录/注册系统,其中包含管理员和标准用户会话,为简单起见,用户可以选择注册用户的权限。 signup.html文件中单选按钮的形式。

    <form action="/signup" method="post">
    <label for="inputEmail" class="sr-only">Email address</label>
    <input type="email" name="inputEmail" id="inputEmail" class="form-control" maxlength="45" placeholder="Email address" required autofocus>
    <label for="inputPassword" class="sr-only">Password</label>
    <input type="password" name="inputPassword" id="inputPassword" class="form-control" maxlength="45" placeholder="Password" required>

<input type="radio" name="userRole" value="standard">Standard
<input type="radio" name="userRole" value="admin">Admin
    <br><br><br>
    <button class="btn btn-lg btn-primary btn-block" type="submit">Signup</button>
  </form>

在我的python代码中,我能够获得用户名和密码,但我不确定如何获得当前点击按钮的值。

if request.method == 'POST':
        _email = request.form['inputEmail']
        _password = request.form['inputPassword']
        _access = request.form[ .... ]

感谢任何帮助,谢谢

1 个答案:

答案 0 :(得分:0)

我的问题的解决方案很简单,它与以前的表单请求完全相同:

private int WIDTH;
private int HEIGHT;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    WIDTH = size.x;
    HEIGHT = size.y;

    pager = (ReadPage)findViewById(R.id.readpage);
    pager.addArticle("...");
}

// ...

public void addArticle(String s){
    articles.add(new Article(s, WIDTH, HEIGHT));
}