...

View Full Version : Changing value of a text box



NeoPuma
10-28-2004, 01: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?
Thanks
-NeoPuma

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

.....Willy

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



<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum