In my science class we stuck a 9v battery into a salt water solution and bubbles came off the to terminals so we put two testing tubes over them, when they were full we took them out of the water and lit a match near them and they went *POW* (very cool to mix hydrogen and oxygen)
Electrolysis is correct but DO NOT use salt as the electrolyte. Salt in this case will only act as a corrosive and destroy the generator much quicker. (I had one last 3 days because the salt ate through it) Using potassium hydroxide is a better option. (It burns cleaner and is more efficient). See more at Dry hho Dry hho generators are also more efficient because the generation of hydrogen and electric current is concentrated into a smaller area. have fun.
With electrolysis. Running a current through water will form hydrogen and oxygen gas in a 2:1 molar ratio. Hydrogen will appear at the cathode, and oxygen will appear at the anode. If the cathode and anode are in separate chambers (test tubes work), the gases can be collected.http://en.wikipedia.org/wiki/Electrolysis_of_waterhttp://www.saskschools.ca/curr_content/chem30_05/graphics/6_graphics/electrolysis_water.gifRemember: Hydrogen and oxygen are both very flammable, although you'd have to collect them in fairly significant quantities to do any real harm.