Wednesday, March 13, 2013

Moving Listitems between two listbox using javascript.

This example shows how to move items between two ListBox. Basically it allows us to move multiple list items from right to left & Left to right on click event.


<!DOCTYPE html>
<html>
    <head>
        <title>move accross List box</title>
        <style>
            .list{
                float: left;
            }
            #list1,#list2{
                width: 100px;
                height:100px;
            }
            input[type='button']{
                width: 30px;
                float: left;
                margin-top: 30px;
            }
        </style>
    </head>
    <body>
        <div class="list">
            <select name="list1" id="list1" multiple="multiple">
                <option value="opt1">opt1</option>
                <option value="opt2">opt2</option>
                <option value="opt3">opt3</option>
                <option value="opt4">opt4</option>
                <option value="opt5">opt5</option>
                <option value="opt6">opt6</option>
                <option value="opt7">opt7</option>
                <option value="opt8">opt8</option>
                <option value="opt9">opt9</option>
                <option value="opt10">opt10</option>
                <option value="opt11">opt11</option>
            </select>
        </div>
        <input type="button" name=">" value=">" onclick="moveacross('list1','list2')">
        <input type="button" name="<" value="<" onclick="moveacross('list2','list1')">
        <div class="list">
            <select name="list2" id="list2" multiple="multiple">
            </select>
        </div>
        <script>
            function moveacross(sourceID, destID) {
                var src = document.getElementById(sourceID);
                var dest = document.getElementById(destID);

                for(var count=0; count < src.options.length; count++) {

                    if(src.options[count].selected == true) {
                            var option = src.options[count];

                            var newOption = document.createElement("option");
                            newOption.value = option.value;
                            newOption.text = option.text;
                            newOption.selected = true;
                            try {
                                     dest.add(newOption, null); //Standard
                                     src.remove(count, null);
                             }catch(error) {
                                     dest.add(newOption); // IE only
                                     src.remove(count);
                             }
                            count--;
                    }
                }
            }
        </script>
    </body>
</html>

and the output is:

Enjoy...

Tuesday, July 17, 2012

Cannot modify header information - headers already sent.


When ever we are dealing with header function the common warnning we get is "Cannot modify header information - headers already sent". 

Lets see php.net mannual -"header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called."  So as it clearly indicate that if our code is generating a space or empty lines also result into this warnning. 

Now the solution: A solution for this is dont allow any output to print any thing on browser till all headers are executed. So we are adding ob_start() in the begnning of page & ob_flush() at the end of page. then what ever is the output will be there in the output buffer, So this time we can use header function without any worry. And your code will somthing like:

<?php
ob_start();
//Your code
header('Location: example.php');
exit()
//your code
ob_flush();
?>
In case we are dealing with session, then session should start after ob_start() otherwise again it will through same warnning.

Friday, June 1, 2012

Reset Your forgotten windows password in easy steps


If you forget windows password, its not easy to reset it. if you dont know the propper tool which can do this. Most of the peoples are using ERD Disk for this. Its working fine upto windows xp, But when they came across windows vista/7 it wont work. So here most of the blogs will suggest to work with sam file (SAM is the file that contains your Windows registry). Its present in directory "WINDOWS/system32/config/". Using linux command chntpw on an Linux live disk we can change the settings. like this,

sudo chntpw –u <username> SAM

Some other similar kind of bootable stuff's are also available for the same.  But in-case if you don't have any one of these stuff or you are not getting it working for you, Now if you can access the windows file system. Then you can still change it. Just applying a simple trick and its all done.

What we have to do is we have to found the window functions which can execute on login screen. lucklly we have a sticky key function, i.e. hitting shift key for 5 times and a popup will come. We know password for any user can be change from command line also.So I think you got me. Exactly we are going to interchange these functions. All these functions are controlled from some files. So if we will interchange the name of files it will work for us. here

Command line the file is: cmd.exe
Sticky key file is: sethc.exe

Both are present in "\windows\system32" directory. so we just need to take the backup of sethc.exe file. this thing can be done from Windows installation disk as well as Linux live disk.

So first go with Windows installation disk:

1. Boot off the Windows disk and select the "Repair your computer" option.
2. Find the option to open the Command Prompt and select it.
3. take the back of stiky file as
copy c:\windows\system32\sethc.exe c:\

4. Replace the stiky file with command prompt file as
copy c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe

5. Reboot your system and on login screen hit shift key 5 times, a command prompt will open in administrator mode.
6. using "net user" command you will get user list present in your system.
7. Now time to change the password as:
net user <username> <password>
Once it says command completed successfully its done.

Now you can log in to your windows System. using your password.
Here you probably want to put back the original sethe.exe file. So you can reboot your system from Windows installation disk and go through step 1 & 2 to get command prompt. and execute the commend
copy c:\sethc.exe c:\windows\system32\sethc.exe
Same thing can be done from linux environment also, Only you need to get this windows directory. 

Saturday, March 31, 2012

Delete option is missing on right click


When we use Right-click on any file or folder in windows OS then Delete/Cut option is suppose to be there. it can be Disabled by doing some registry settings or from group policy Editor.But in some cases when we are using external Storage devices if not unplugged properly, Causes some times Side-effect to the filesystem settings then it's Delete/Cut option got disabled. so when ever we Right-click on some file or folder we wont get Delete or Cut option, Not even Delete button will work on that partition to delete the file.

                                                  

It happens with me. i am using 1TB External HDD, Using Windows7 i created 4 partition Each of 250GB,Filesystem: exFAT, Sometimes when i was in hurry i have ejected that hard-drive without proper Ejection. That has created some effect on filesystem & was not able to delete any file or folder from that hard-disk but was able to Copy/Paste files from there, cut Option! also was missing.
i was having lots of data on that hard-disk which i dont want to loose by  formatting the hard-disk.
Solution: Which ever partition is having this problem Right-click on Partition and Select Property. Select Tools Tab And in Error-Checking Section Click on Check now button. Now one popup will come Check Automatically fix file system errors.

After Completion of this Process the Delete & cut Option will be there on right click.