www.webdeveloper.com
Results 1 to 5 of 5

Thread: Add font tags to selected text in textbox or textarea

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    12

    Add font tags to selected text in textbox or textarea

    HI,
    I want to increase the size of font using the select option for the selected text. Also by selecting the size the selected text must be viewed in the textbox like

    <font size="3">welcome</font>
    Please anyone tell me how to do this.

  2. #2
    Join Date
    Dec 2012
    Location
    NSW Australia
    Posts
    73
    you cannot do that!!!

    well not any more with the new html5 and not in my book either.

    Use css instead and then add a class to the element in question.

    might be an advantage if you show what you have done so we can get an idea to what you are trying to do.

  3. #3
    Join Date
    Mar 2013
    Posts
    12
    Sure.The following is my code.
    Code:
    function font(elems,tag,size){
    var i=0, el, selectedText, newText;
    while(el=elems[i++]){
    selectedText=document.selection?document.selection.createRange().text:el.value.substring(el.selectionStart,el.selectionEnd);// IE:Moz
    if(selectedText!=''){
    	newText='<'+tag+" size="+size+'>'+selectedText+'</'+tag+'>';
    		if(document.selection){//IE
    		document.selection.createRange().text=newText;
    		return;//prevents the double replacement
    		}
    		else{//Moz
    		el.value=el.value.substring(0,el.selectionStart)+newText+el.value.substring(el.selectionEnd,el.value.length);
    		}
    	}
    }
    
    }
    
    Font size:
    <select name="sizeselect" onchange="font([ques1,ques2,opt1,opt2,opt3,opt4],'font',this.value)">
     <option value="select">select</option>
     <option value="10">10</option>
     <option value="13">13</option>
     <option value="15">15</option>
     <option value="17">17</option>
     <option value="19">19</option>
     <option value="21">21</option>
     <option value="23">23</option>
     <option value="50">50</option>
    </select>
    Actually what i'm trying to do is, take our reply option as example. While u r clicking reply, the textarea with font name select,size select, color select is there.Like this i'm trying to do.

  4. #4
    Join Date
    Mar 2013
    Posts
    12
    Otherwise please tell me, is it possible to do the select box for font name and size also the color palatte and mathematical expressions.
    I'm entering a text like "Hi, Welcome to w3schools.invisionzone.com" in a textbox. Now what i want to do is, i want to select the size,name color of font from the select box and after selecting the values i'll select the entered text from textarea, for example "w3schools.invisionzone.com". After selecting all these if i click a font button all the selected values has to be viewed inside the font tag as
    <font size="3" name="times new roman" color="red">"w3schools.invisionzone.com"</font> in my textarea.How shall i do this.Please tell me.

  5. #5
    Join Date
    Dec 2012
    Location
    NSW Australia
    Posts
    73
    I guessed that was what you were trying to do..

    What you will have to do is see if you can con the admins to give you the code for this sites text box...

    Last time I did sum fancy stuff like in this reply box and what you are after was with a plugin...
    Please do not ask the name as I do not remember.... Maybe some-one else may know of one.

    If you are willing to learn things your self try some homework

    EG i found this in a few seconds

    help.dottoro.com/ljrvjsfe.php


    In the mean time when I have time and not to grumpy and tired I may have a look myself just to refresh my memory.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles