Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is probably a simple thing but I can't get it to work.

Given the following script:
XML
<html>
<body>
    <script>
        var model = {
            count: 10,
            page: 1,
            pages:1
        };

        function rowsperpage(c) {
            model.count = c;
            model.page = 1;
            doquery();
        }

        function page(i)
        {
            model.page += i;
            if (model.page == 0) model.page = 1;
            if (model.page > model.pages) model.page = model.pages;
            doquery();
        }

        function doquery() {
            alert(model.count);
        }
    </script>
    <button style="width:200px;height:40px" onclick="doquery()">Run</button>
    <br><br>
    <a href="" onclick="page(1)">next</a>
    <a onclick="rowsperpage(100)" href="">100</a>
</body>
</html>


- if I click on the 100 link I get a "100" alert which is wanted
- if after the above I click on the "Run" button I get a "10" alert which means the 100 value is lost

How can I get the above to keep it's state.
Posted

1 solution

Put a # in all the href so that the page stays after being clicked:
href="#"
 
Share this answer
 
v2
Comments
Mehdi Gholam 23-Mar-15 12:36pm    
Simple when you know! 5'ed thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900