If a mattress has been underwater for more than 24 hours, or was wet with flood water that could contain sewage, fuel or other contaminants, throw it away rather than attempt to save it. Foam mattresses, too, are usually not salvageable, but you can attempt to save one using the same methods you would for any other mattress. If you're dealing with rainwater or another clean water source, you may be able to dry and save the mattress if you act quickly. You will need to get as much water out of the mattress as possible and treat it to prevent mold growth.
Press clean towels into the mattress everywhere that it is wet, applying as much pressure as you can. The towels will soak up some of the water from the mattress. Get as much water out this way as you can.
Sprinkle the mattress with baking soda and allow it to sit for about 12 hours to soak up the water. Push the powder into the mattress to reach as much water as you can.
Remove the baking soda with a wet-dry vacuum cleaner. This will protect you from electric shock if the vacuum pulls some moisture out of the mattress as you work. Reapply more baking soda and repeat the process if you think more moisture could be pulled from the mattress.
To prevent mold from developing on the mattress, create a cleaning solution by combining 1 cup of water and 1 cup of rubbing alcohol. Dip a clean cloth into the solution, wring it out well, and then rub the cloth over the surface of the mattress.
Move the mattress outside to a sunny spot to dry. Prop the mattress in an upright position so that air can circulate around both sides. If the weather makes this impossible, place a fan in the room to blow air across the mattress. The mattress could take an entire day to dry and must be completely dry before being used.