Question
storing whitespace in db that comes from textarea
hi guys,
i am taking user input from a textarea in a form and saving that in my db.
as we all know when one does that the whitespace is sent from the browser to the server but from there on it can get 'lost'
in a previous application i built i think i did something like this -- replace(form.text_from_textares,chr(10),"<br />,"all") -- and then stuck that in the db
but to be fair i never really understood exactly what chr(10) represented and if that was infaliable (ie did it catch all 'white space'?)
anyway - i dont think this is ideal as if one then want to search for a string that is broken up with a carridge return or similar your search code would be unlikely to find it as you've gone and stuck a BR tag in the middle of it.
what is considered best practice here?
PS if anyone is able to explain the differences between CR and LF and what they're all about that would be great!
PPS what's with the "wrap" attribute in textarea - is that depreciated now?
PPPS would using the regex shortcut of \s be a way to tackle this issue?
thanks in advance
Nick
i am taking user input from a textarea in a form and saving that in my db.
as we all know when one does that the whitespace is sent from the browser to the server but from there on it can get 'lost'
in a previous application i built i think i did something like this -- replace(form.text_from_textares,chr(10),"<br />,"all") -- and then stuck that in the db
but to be fair i never really understood exactly what chr(10) represented and if that was infaliable (ie did it catch all 'white space'?)
anyway - i dont think this is ideal as if one then want to search for a string that is broken up with a carridge return or similar your search code would be unlikely to find it as you've gone and stuck a BR tag in the middle of it.
what is considered best practice here?
PS if anyone is able to explain the differences between CR and LF and what they're all about that would be great!
PPS what's with the "wrap" attribute in textarea - is that depreciated now?
PPPS would using the regex shortcut of \s be a way to tackle this issue?
thanks in advance
Nick