[Solved] Why this snippet is not working? [closed]


Replace with:

jQuery(document).ready(function(){
    $("#button").click(function() { 
        var email_id=document.getElementById('textfield').value;
        var password=document.getElementById('textfield2').value;
        var utype=document.getElementById("utype").value;
        var url="login_check.jsp?&email_id="+encodeURIComponent(email_id)+"&password="+encodeURIComponent(password)+"&utype="+encodeURIComponent(utype);
        $('form').get(0).setAttribute('action',url);  
        alert(document.form1.action);    
    });
});

Also see this example.

=== UPDATE 2 ===

Here a short version:

HTML:

<form name="form1" action="login_check.jsp">
    <input type="text" name="email_id">
    <input type="text" name="password">
    <input type="text" name="utype">
    <input type="submit" id="button" value="submit">
</form>

JS (is not neccessary if you don’t want to do more):

$(document).ready(function(){
    $("#button").click(function() {
        $('form').prop('action', "login_check.jsp?" + $('form').serialize());
    });
});

And an example.

1

solved Why this snippet is not working? [closed]