Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-28-2004, 01:14 AM   PM User | #1
NeoPuma
Regular Coder

 
Join Date: Oct 2004
Posts: 104
Thanks: 7
Thanked 2 Times in 2 Posts
NeoPuma is an unknown quantity at this point
Changing value of a text box

Hi there,
Just like this forum got, you have a button saying 'B'. when you click it, it adds the Bold tag, making all text after it bold, untill the end tag. What I want to do is simply, make a short javascript (function), which will have 2 vars, so like:
Code:
function bold(form, textbox)
I have no idea if that will work, as this is my very first thing in javascript. When the button 'B' (Form input type="Button") is pushed, I want to add [B] onto the end of document.form.textbox.value.

How would I do this?
Thanks
-NeoPuma
NeoPuma is offline   Reply With Quote
Old 10-28-2004, 09:42 AM   PM User | #2
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Try searching the forum using the keywords: insert bbCode

This question has been asked numerous times and there are quite a few examples floating about....

.....Willy
Willy Duitt is offline   Reply With Quote
Old 10-28-2004, 09:44 AM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
I think the easiest way is by changing CSS "on-the-fly"

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<
html>
<
head>
<
title>Untitled Document</title>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
meta http-equiv="Content-Style-Type" content="text/css">
<
meta http-equiv="Content-Script-Type" content="text/javascript">
<
script language="JavaScript" type="text/JavaScript">
function 
boldT(f,t){
f.elements[t].style.fontWeight='bold';
}
</script>
</head>
<body>
<form>
<input name="textbox" type="text">
  <input type="button" onclick="boldT(this.form,'textbox')" value="Bold">
</form>
</body>
</html> 
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:56 PM.


Advertisement
Log in to turn off these ads.