在onclick javascript函数上使用标记html

时间:2015-11-01 13:59:00

标签: javascript html

你好我的HTML中的标签有问题,我想使用a标签来调用我在js文件夹中的java脚本函数,我有我所有的javascripts。我已经尝试寻找答案,但我没有找到任何可以解决我的问题的答案。我知道这个功能正在运行,因为如果我尝试使用输入onclick on a on on on,它正在工作,但是在美学方面,标签效果更好。我有这个代码

这是我的函数,它位于文件夹/ myProject / Source Files / js

function formhash(form, password) {
    // Create a new element input, this will be our hashed password field. 
    var p = document.createElement("input");

    // Add the new element to our form. 
    form.appendChild(p);
    p.name = "p";
    p.type = "hidden";
    p.value = hex_sha512(password.value);

    // Make sure the plaintext password doesn't get sent. 
    password.value = "";

    // Finally submit the form. 
    form.submit();    
}

我的HTML页面包含:

<div class="user_login">
    <form action="includes/process_login.php" method="post" name="login_form">
        <label>Email / Username</label> <input type="text" name="email" /> <br /> <label>Password</label>
        <input type="password" name="password" id="password"/> <br />

        <div class="action_btnns">
            <div class="one_half">
                <a href="#" class="btnn back_btn"><i
                                            class="fa fa-angle-double-left"></i> Back</a>
            </div>
            <div class="one_half last">
                <a  class="btnn btnn_red" href="javascript:void(0);" onclick="formhash(this.form, this.form.password)">Login</a>
                <!--<input class ="btnn btnn_red" value='Login' onclick='return formhash(this.form, this.form.password);'-->
             </div>
        </div>
    </form>

    <a href="#" class="forgot_password">Forgot password?</a>
</div>

如果我按下按钮登录,在我的页面中什么也没发生。如果你能帮助我,那就太棒了,谢谢你

0 个答案:

没有答案
相关问题