Welcome back to Hack.5 I am here to give you another cool tip. To start I want to go into javascript. A lot of times it is a pain on the butt when you are trying to view pages or just pagination really, really fast since I am doing this page request. Well I got a trick for you. Let us go and let us get started we are going to only use javascript in HTML. So we are going to go ahead and create a function in javascript called sure page or what ever you decide to do and it is going to accept an ID. Next we are going to create a variables it is going to have the total number of pages now there are a lot of flexibility where you can change this where it is set dynamically. I would not had and set it in two since the HTML is only going to be handling two pages.
Next we are going to go ahead and create a four loop. This is a really cool trick when you are managing lots of pages or you want to do some pagination instead of specifically hiding those div tags one by one by one, just to do a four loop hide all of them and only show the one that you want to display. So that is basically the idea of the way that this could have set up however there are a lot of flexibility with it because you can set this stuff server side or for using Ajax or you can set it client side if you just take them with some javascript. Next one you just go in to your actual HTML and I wanted heading created a simple ID navigation and set 2 links to say click here to display page one or page two. now on click will going to actually call that function past it that ID for this example we have we have one and two or you can dynamically set it and it will call that function hide all of this div tags and then only display the ID that you sent it so if I click page two I am sending the number 2 to it and then it just displays that page.
Next we are just going into the actual style. It is going to involve very, very little CSS. The important part is you actually want to set that div tag to a style display none. None is actually going to hide the div tag on the page load then when you actually call the function and set that div tag you are going to input the display block and it actually blocks all the styles of that page specifically none. So that is your basic cool tip for the day for some javascript hope you guys enjoyed, see you soon.
You have been watching a segment from Hak5
Get more great technolust at www.Hak5.org
[Music Playing]
Transcription by:
Scribe4you Transcription Services