Tuesday, March 20, 2018

Send html attribute value from one page to another page using jquery

<html>
    <head>
        <title>Jquery Example</title>
    </head>
    <body>
        <form id="page1_form" name="page1_form" method="post">
            <h2>Send html attribute value from one page to another page using jquery</h2>
            <input type="hidden" name="Id" value="-1" />
            <input type="button" class="btnButton" name="btn" value='btn' id="5" >
        </form>
    </body>
</html>
<script>
$(document).ready(function() {
    $("input.btnButton:button").click(function () {
        ID = $(this).attr("id");
        if (parseInt(ID) > 0) {
            $("#page1_form input[name=Id]").val(ID);
            $("#page1_form").attr("action", "page2.php");
            $("#page1_form").submit();
        }
    });
    });
</script>

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...