Results 1 to 8 of 8
  1. #1
    Dino
    Guest

    Add Text to a Textarea or Text Field - HELP!

    At this page: http://www.mediacollege.com/internet.../add-text.html

    It gives me the option to append text to a textarea box, but I'm looking to have multiple sources and one output box (for use to create custom emails in a web based email program with a few clicks of a mouse).

    I'm having problems trying to create multiple sources. The javascript that enables the append option has a source and destination that are defined. How would I use multiple sources and only one destination?

    Can anyone help?

    -Dino

  2. #2
    Dino
    Guest
    I think I may have answered my own question after fiddling with this thing for a while..

    This works:

    <html>
    <head>
    <script language="javascript" type="text/javascript">
    function addtext1() {
    var newtext1 = document.myform.inputtext1.value;
    document.myform.outputtext.value += newtext1;
    }
    </script>

    <script language="javascript" type="text/javascript">
    function addtext2() {

    var newtext2 = document.myform.inputtext2.value;
    document.myform.outputtext.value += newtext2;
    }
    </script>


    <form name="myform">

    <textarea name="inputtext1" cols="25" rows="4">Option one... </textarea>
    <input type="button" value="Option One" onClick="addtext1();">

    <textarea name="inputtext2" cols="25" rows="4">Option two... </textarea>
    <input type="button" value="Option two" onClick="addtext2();">



    <textarea name="outputtext" cols="30" rows="25">Dear </textarea>



    </form>



    <!--next-->
    </body>
    </html>

  3. #3
    Dino
    Guest
    New problem.

    When I click a button to add text to the next line, I want to be able to add a carriage return/CTRL-M to the text so that the text does not just follow the next line

    Any ideas how to do this?

    -Dino

  4. #4
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    The code for a carriage return is "\n". Use the following code to add a return:

    var newtext1 = "\n" + document.myform.inputtext1.value;
    Dave Owen
    MediaCollege.com

  5. #5
    Gary
    Guest
    I have tried making a drop down add information to the text area but this does not seem to work. But the page does not error.

    Any ideas?

  6. #6
    Administrator Dave's Avatar
    Join Date
    Sep 2004
    Location
    Te Awamutu, New Zealand
    Posts
    3,959
    Blog Entries
    79
    Hi Gary,

    You'll need to show us the URL or the code you're using, otherwise we have no way of knowing what's going on.
    Dave Owen
    MediaCollege.com

  7. #7
    New Member
    Join Date
    May 2010
    Location
    malaysia
    Posts
    1

    help

    how to add text to text field and another textfield.

  8. #8
    New Member
    Join Date
    Dec 2010
    Location
    AF
    Posts
    1
    How would I use information passed into a textarea for further processing? Would I need to create a new variable for that? The two scripts work separately with their respective textarea boxes. They fail to function together, however. How would I change that? Thanks so much in advance!

    Code:
    <HTML> 
     
    <HEAD> 
    
      <TITLE>Message Reminder</TITLE>  
    <font face="sans-serif" color="green">
    <style type="text/css">
     input.btn { 
    	  color:#050; 
    	  font: bold 84%'trebuchet ms',helvetica,sans-serif; 
    	  background-color: #fed; 
    	} 
     </style>
    <script language="javascript" type="text/javascript">       
    /* Visit http://www.yaldex.com/ for full source code
    and get more free JavaScript, CSS and DHTML scripts! */
    <!-- Begin
    var text = "";
    function getActiveText(e) {
    
    // Sets text MSIE or Netscape active
    // text based on browser, puts text in form
    message = (document.all) ? document.selection.createRange().message : document.getSelection();
    
    document.theform.message.value = message;
    return true;
    }
    
    document.onmouseup = getActiveText;
    if (!document.all) document.captureEvents(Event.MOUSEUP);
    //  End -->
    </script>
    
     <SCRIPT language="javascript"> 
    var timer = null
    var running=false
    function Start_Timer() {
    	hours = parseInt(document.Timer_Program.Hours.value);                                  	minutes = parseInt(document.Timer_Program.Minutes.value);
    	seconds = parseInt(document.Timer_Program.Seconds.value);
    	
    	time_stop = (hours*3600) + (minutes*60) + seconds
    	if(time_stop > 0) {
    		document.Timer_Program.Status.value="Running";
    		var timer= setTimeout("window.focus();window.alert
    
    (document.Timer_Program.message.value);document.Timer_Program.Status.value='Stopped';",time_stop *1000);
    var timer= setTimeout("window.focus();window.alert(document.Timer_Program.message.value);document.Timer_Program.Status.value='Stopped';",time_stop 
    
    *2000);
    var timer= setTimeout("window.focus();window.alert(document.Timer_Program.message.value);document.Timer_Program.Status.value='Stopped';",time_stop 
    
    *3000);
    var timer= setTimeout("window.focus();window.alert(document.Timer_Program.message.value);document.Timer_Program.Status.value='Stopped';",time_stop 
    
    *4000);
    var timer= setTimeout("window.focus();window.alert(document.Timer_Program.message.value);document.Timer_Program.Status.value='Stopped';",time_stop 
    
    *5000);
    	}
    	else window.alert("The time is improper.")
    }
     
     
    </script>
    
      
    <FORM Name="Timer_Program"> 
    
      
      <INPUT TYPE="text" NAME="Seconds" Value="0" SIZE="5">Seconds 
      <INPUT TYPE="text" NAME="Minutes" Value="0" SIZE="5"> Minutes
      <INPUT TYPE="text" NAME="Hours" Value="0" SIZE="5">Hours<DT> 
      <P>  
    <b>Try highlighting some of this tex.</b><BR><br>
    <form name=theform>
    Selected text:  
    <textarea name=message=value="" rows="5" cols="40">
    
    </textarea>
    
    
    <P> 
    <INPUT TYPE=button value="Start" NAME="Start" color: white onClick= "running=true;clearTimeout(timer);Start_Timer();">&nbsp&nbsp&nbsp&nbsp 
    <INPUT TYPE=button value="Stop" NAME="Stop" onClick= "running=false;document.Timer_Program.Status.value='Stopped';clearTimeout
    
    (timer)">&nbsp&nbsp 
    <INPUT TYPE="text" NAME="Status" Value="Stopped" SIZE="10">(Status)<DT> 
    
    </FORM> 
    </BODY></HTML>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Subscribe to us on YouTube