JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 9th, 2004, 12:38 AM
CHornJr's Avatar
CHornJr CHornJr is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Location: New York City
Posts: 233 CHornJr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 50 m 19 sec
Reputation Power: 6
Send a message via AIM to CHornJr Send a message via MSN to CHornJr Send a message via Yahoo to CHornJr
Angry code similar to vbcode or bbcode replacing the textarea

on my site I have a simple form for site administrators to use to add news articles or calendar events to the site. We ran into a problem with someone using html. They forgot to close a tag and it caused some minor problems. We decided to then strip all html from anything people want to post so that can't happen again. However we do want the ability for admins to post links and make text bold and stuff like that. We set up some code to do this. it may works similar to how posting a message here work but, probably a whole lot more simplistic. The only problem we have is when the user clicks the b for bold instead of placing the appropriate code in the textarea where the curser is, it replaces what is already in the textarea. So how can I get the javascript to put in the code in the textarea without replacing the text already there.

here is the code we have in our test form
Code:
<script language="JavaScript">
var display_text=new Array("Test 1","Test 2");
var display_text_a="";
function button_test(display_text_a)
{
document.test.text.value=display_text[display_text_a]+" and "+display_text[display_text_a];
}
function insertcode(display_text_a)
{
document.test.text2.value=display_text[display_text_a]+" and "+display_text[display_text_a];
}
</script> 
<form name="test">
<input type="button" name="test" onmouseover="button_test(0)" onclick="insertcode(0)" value="test 1" />
<input type="button" name="test" onmouseover="button_test(1)" onclick="insertcode(1)" value="test 2" />
<input type="text" name="text" disabled>
<textarea name="text2"></textarea>
</form> 
__________________
CHornJr
"One day I'll know what I am doing"
My Blog
Suanhacky Lodge #49
Rebel Squadrons

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > code similar to vbcode or bbcode replacing the textarea


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway