View Full Version : format my thread
ahmedsoliman
05-24-2003, 12:14 PM
i need to creat text area like this in new thread, so when select specific text then click on the B button, it placed between two [b] bracket
[ b ] mytext [ /b ]
and so the color,font,size drop down box
i need easy code for this
thanks for all
:)
ahmedsoliman
05-25-2003, 09:47 AM
any answer please :(
shlagish
05-26-2003, 02:04 AM
I didn't test it, but something like this might work...
<html>
<head>
<script type="text/javascript">
<!--
function add(what)
{
var new_text=prompt("Write the text to become bold in the box","");
var new_new_text="["+what+"]"+new_text+"[/"+what+"]";
document.text.value=document.text.value+new_new_text;
}
-->
</script>
</head>
<body>
<input type="button" value="B" onClick="add('b')">
<input type="button" value="I" onClick="add('i')">
<input type="button" value="U" onClick="add('u')">
<br />
<textarea id="text" cols="25" rows="16">
</textarea>
</body>
</html>
I didn't do size, font, color, http://, @, IMG, #, PHP, List and Quote, but it's pretty much the same thing I guess
ahmedsoliman
05-28-2003, 03:27 PM
Thanks shlagish but how to call the same function with dropdown box.
second question is how to make change occure on selected text in text area without display promt, such as notepad.
shlagish
05-28-2003, 10:57 PM
Well, for the dropdown it's the same except you could add a second attribute to the function
<select>
<option>size
<option>
<a href="#null" onClick="add('size','3')">3</a>
</select>
Then the function would be:
function add(what,which)
{
var new_text=prompt("Write the text to become bold in the resized","");
var new_new_text="["+what+"="+which+"]"+new_text+"[/"+what+"]";
document.text.value=document.text.value+new_new_text;
}
And then it's the same for font, but you change the attributes you use to call the function:
so instead of using:
<select>
<option>size
<option>
<a href="#null" onClick="add('size','3')">3</a>
</select>
you use
<select>
<option>size
<option>
<a href="#null" onClick="add('font','red')">red</a>
</select>
btw, I'm not sure about the syntax of a dropdown menu, but I don't have time to check, sorry
For the "no prompt" thing, I just don't have any idea, sorry.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.