Posted by : my solutions Monday, December 17, 2012



I' M Demonstrated this example by using two basic html pages in the visual studio 2010 and one .Js File

All are very familiar to pass values by using "Querystring" , same thing i done by used plain HTML


if u pass the one html page to another page page , we are hardly able to maintain the state between the Html pages.

Example :- Two Html pages "A" and "B"  ( Checkbox checked into "A" and move to "B" Html page)
                       again Come back to "A" Html Page means The checked always disabled

Cause :- State maintain error Between / among the Html Pages

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $(go).click(function () {
                if (document.getElementById("check1").checked = true) {
                    window.location.href = "HTMl2.htm?code=maruthi";
                }
                else {
                    window.location.href = "first.htm";
                }
            });
        });
        function check() {
        var query = window.location.search.substring(1);
            var parms = query.split('&');
            for (var i = 0; i < parms.length; i++) {
                var pos = parms[i].indexOf('=');
                if (pos > 0) {
                    var key = parms[i].substring(0, pos);
                    var val = parms[i].substring(pos + 1);
                }
                if (val == "maruthi") {
                    document.getElementById("check1").checked = true;
                }
            }
       }
</script>
</head>
<body onload="check();">
<input type="checkbox" id="check1">two?
<input type="checkbox" id="Checkbox1">one?
<input type="checkbox" id="Checkbox2">three?
<input type="checkbox" id="Checkbox3">four?

<input type="button" value="click me" id="btncl" onclick="m();" />
<a href="#" id="go">click</a>

</body>
</html>

--------------------------------------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>querystring</title>
    <script src="jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(bck).click(function () {
                window.location.href = "First.htm?code=maruthi&code2=pallamalli";
            });
        });
    </script>
    <script type="text/javascript">
        var qsparam = new Array();
        function qs() {
            var query = window.location.search.substring(1);
            var parms = query.split('&');
            for (var i = 0; i < parms.length; i++) {
                var pos = parms[i].indexOf('=');
                if (pos > 0) {
                    var key = parms[i].substring(0, pos);
                    var val = parms[i].substring(pos + 1);
                }
                alert(val.toString());
            }
        }
 
    </script>
</head>
<body>
<h1>hi</h1>
<a href="#" id="bck">back</a>
<input type="button" value="show string" onclick="qs();" />
</body>
</html>

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © complete .net tutorials - Skyblue - Powered by Blogger - Designed by Johanes Djogan -