Jump to content

PHP, JS and HTML. Displaying form.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
jaydee

jaydee

    Newbie

  • Members
  • PipPip
  • 17 posts
Right, ok

Posted a while ago with another problem I had, here goes the next.

Right the forum I'm designing which I have done from scratch isn't having that many features so keeping it lightweight. I want to have a function where using javascript, when the user clicks 'edit' to edit there post, the text in the post disappears, replaced by a textbox with the original text in the text box ready to be edited, I'll then use the JS onBlur function to save it. I've got as far as making the text box appear, now in the textarea tags I use like the below:
<textarea <?php echo $thetext; ?> </textarea>

This works, apart from where the lines break it shows break tags <br>. They don't show up when just displaying the text, only in the text box. Anyone have any ideas how to make this work, is it browser compatibility or..?

Thanks in advance.

#2
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Already a topic on this mate... one that I need help with also :P!!

http://forum.codecal...xes-br-php.html

Apparently there are two ways of doing it, there may be some replies in that threat that are of interest to you :)!

#3
jaydee

jaydee

    Newbie

  • Members
  • PipPip
  • 17 posts
I think your problem is a little bit different, I'm not sure.

I need to both display the data staticly, and the same text displayable with the line breaks in the textarea

#4
Furry Pancake

Furry Pancake

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Sorry for the outside link, but I was wondering the same thing a couple weeks ago..

I found this script, Ajax flickr like edit: Flickr Like Edit Examples

I hope that works man :) and I sure hope that is what you were asking.. Lol, that is what I got out of it :)

#5
TriggerHappy

TriggerHappy

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
$thetext = str_replace('<br>', '\n', $thetext)

Should work.

#6
Furry Pancake

Furry Pancake

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts

TriggerHappy said:

$thetext = str_replace('<br>', '\n', $thetext)

Should work.

You put me to shame. Thank you :)

#7
TriggerHappy

TriggerHappy

    Learning Programmer

  • Members
  • PipPipPip
  • 30 posts
There is also another function which does the same as the above, though it's probably faster and it's also shorter to type. I'm sure someone will come along and show it.

#8
jaydee

jaydee

    Newbie

  • Members
  • PipPip
  • 17 posts

TriggerHappy said:

$thetext = str_replace('<br>', '\n', $thetext)

Should work.

Worked perfect, thanks :)