Jump to content

Javascript paste? I need help please


da_cracken

Recommended Posts

Hi,
   I need help please. I'm working on a script to paste items into a text area. The scipt pastes, but it pastes where it wants to paste, and not where i want it to go. I want it to paste at the text selector, but it only pastes at the very end of any text already in the box. I have pasted a small part of the script below and I pray someone can figure out the error of my ways for me ;D

function BR()
{
document.Pro.write.value += ("<BR>\n")
}
Link to comment
https://forums.phpfreaks.com/topic/19622-javascript-paste-i-need-help-please/
Share on other sites

Because that is what you are telling it do. The += adds whats on the right to the end of whats on the left. So its always going to add [nobbc]<br>[/nobbc] on to the end of whats in you textarea

If you want to get javascript to add [nobbc]<br>[/nobbc] where your curser is, then it'll be a bit more advanced as you'll have to use javascript find out where the curser is located to and then get it to add br tag in that location.

Also whay are you adding br tag into a textarea anyway? If its to preserver line breaks. Dont bother just use the nl2br PHP function to preserve the line breaks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.