开发者

Submit hidden form once upon clicking text

开发者 https://www.devze.com 2023-04-09 06:57 出处:网络
I have a set of members who have stored their login credentials (usr | pwd) of other websites as our partners. As is the situation, I am supposed to provide them just a text link and submit a form upo

I have a set of members who have stored their login credentials (usr | pwd) of other websites as our partners. As is the situation, I am supposed to provide them just a text link and submit a form upon clicking that link.

    // 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/javascr开发者_如何学JAVAipt" 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>

The problem is that the form submits twice upon clicking the link. And subsequently the landing page says its a string error.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号