View Full Version : Changing value of a text box

10-28-2004, 02:14 AM
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:

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?

Willy Duitt
10-28-2004, 10:42 AM
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....


10-28-2004, 10:44 AM
I think the easiest way is by changing CSS "on-the-fly"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<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){
<input name="textbox" type="text">
<input type="button" onclick="boldT(this.form,'textbox')" value="Bold">