Hey, i assume when you say foam you mean open cell foam, or upolstry foam? If that is the case, i have always used a product called Barge Cement. Its a type of rubber cement that is used to attach the soles of shoes to the leather. It works wonders on foam and it stays flexible when dry. Also spray 90, an arisol adhesive you can get at any home depot or lowes also will work, but is generaly beter for attaching sheets toghether. I hope this helped!