单击文本后提交隐藏表单

时间:2011-09-30 10:18:21

标签: javascript jquery click

我有一组会员已将其他网站的登录凭据(usr | pwd)存储为我们的合作伙伴。根据情况,我应该只提供一个文本链接,并在点击该链接时提交表单。

    // Getting values from db and storing them in javascript variables

    <script type="text/javascript">
    // values from db stored in javascript variables
       var at_Cara = "<? echo $at;?>";  
        var ln_Cara = "<? echo $ln;?>"; 
        var wd_Cara = "<? echo $pw;?>";
    </script>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript">

    // I am submitting a form with hidden values, which is as follows:
        $(document).ready(function() {
        $("#goto").click(function() {
            var site = "http://franka.finexp.net/login.aspx";
            $('<input>').attr({type: 'hidden',id: 'Auto',name: 'Auto',value: at_Cara}).appendTo('#valgoogexp');
            $('<input>').attr({type: 'hidden',id: 'LoginName',name: 'LoginName',value: do_ln_Cara}).appendTo('#valgoogexp');
            $('<input>').attr({type: 'hidden',id: 'Password',name: 'Password',value: wd_Cara}).appendTo('#valgoogexp');
            $("#valgoogexp").attr("action", site);
            $("#valgoogexp").submit();
        }); 
            return false;
        });
    </script>

    <a href="javascript:void(0);" id="goto" >Research Tool</a>
    <form id="valgoogexp"></form>

问题是表单在点击链接时提交了两次。随后着陆页显示字符串错误。

0 个答案:

没有答案