Jump to content

Archived

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

da_cracken

Javascript paste? I need help please

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")
}

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.