dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: make table appear in textarea with input color and font face

  1. #1
    Join Date
    Jan 2010
    Posts
    73

    Question make table appear in textarea with input color and font face

    ====================first window===========================
    <html>
    <head>
    <script language="javascript">
    var newWindow;
    function call() {
    newWindow=window.open("gagut.html", "gagut")
    }
    </script>
    </head>
    <body>
    <form>
    MATHEMATICS <INPUT TYPE="TEXT" NAME="math" SIZE="5"><br>
    ENGLISH <INPUT TYPE="TEXT" NAME="eng" SIZE="5"><br>
    <br>
    <input type="button" name="add" value="RESULT" onClick="call()">
    </form>
    </body>
    </html>

    ===================second window===========================

    <html>
    <head>
    <script language="javascript">
    function getIt() {

    var fMath=self.opener.document.forms[0].math.value;
    strMath=fMath.toUpperCase();
    if(strMath.length==0) {
    opener.alert("Please enter score for Mathematics");
    }
    if(isNaN(strMath)) {
    opener.alert("Please enter figure for Mathematics");
    //strMath="";
    }

    var goodness="<HTML><BODY><CENTER><TABLE CELLPADDING=0, CELLSPACING=15 BGCOLOR=BLUE>"
    goodness +="<CAPTION><ALIGN=TOP><B><U><FONT COLOR=MAROON> SUBJECT / SCORE " +"</FONT></U></B></CAPTION>"
    if(strMath.length==0) {
    strMath=0;
    goodness +="<TR><TD ALIGN=RIGHT><B>MATHEMATICS :<B></TD>" +"<TD><I>" +"ABSENT" +"</I></TD>";

    }
    else{
    goodness +="<TR><TD ALIGN=RIGHT><B>MATHEMATICS <B></TD>" +"<TD><I>" +strMath +"</I></TD>";
    }

    //-------------------validating English values------------------------+

    var fEng=self.opener.document.forms[0].eng.value;
    strEng=fEng.toUpperCase();
    if(strEng.length==0) {
    opener.alert("Please enter score for English");
    }
    if(isNaN(strEng)) {
    opener.alert("Please enter figure for English");
    //strEng="";
    }
    if(strEng.length==0) {
    strEng=0;
    goodness +="<TD ALIGN=RIGHT><B>ENGLISH <B></TD>" +"<TD><I>" +"ABSENT" +"</I></TD></TR>";
    }
    else{
    goodness +="<TD ALIGN=RIGHT><B>ENGLISH <B></TD>" +"<TD><I>" +strEng +"</I></TD></TR>";
    }

    goodness +="</TABLE></CENTER></BODY></HTML><BR></BR>";
    document.myForm.textMe.value = goodness;
    document.myForm.textMe.style.color="red"
    //document.myForm.textMe.style.face="verdana"

    /*var result, nMath, nEng;

    nMath=parseInt(strMath);
    nEng=parseInt(strEng);
    result = nMath+nEng;*/

    }
    </script>
    </head>
    <body onLoad="getIt()">
    <form name="myForm">
    <textarea name="textMe" cols=30 rows=30 readonly></textarea><br>
    <input type="button" name="submit" value="SUBMIT">
    </form>
    </body>
    </html>

    thanks. Please this i need your help for,. When i input data from the first window it appears in the textarea of the second window retrieving the table tags, this is not what i want. i want the the table to come out as a table and the content from the first window to appear in the table, in the textarea of the second window with color blue and font face - lucida console like this:

    MATHEMATICS 60
    ENGLISH 70
    RESULT 130

    Thanks. God bless.

  2. #2
    Join Date
    Jan 2010
    Posts
    73
    ====================first window===========================
    <html>
    <head>
    <script language="javascript">
    var newWindow;
    function call() {
    newWindow=window.open("gagut.html", "gagut")
    }
    </script>
    </head>
    <body>
    <form>
    MATHEMATICS <INPUT TYPE="TEXT" NAME="math" SIZE="5"><br>
    ENGLISH <INPUT TYPE="TEXT" NAME="eng" SIZE="5"><br>
    <br>
    <input type="button" name="add" value="RESULT" onClick="call()">
    </form>
    </body>
    </html>

    ===================second window===========================

    <html>
    <head>
    <script language="javascript">
    function getIt() {

    var fMath=self.opener.document.forms[0].math.value;
    strMath=fMath.toUpperCase();
    if(strMath.length==0) {
    opener.alert("Please enter score for Mathematics");
    }
    if(isNaN(strMath)) {
    opener.alert("Please enter figure for Mathematics");
    //strMath="";
    }

    var goodness="<HTML><BODY><CENTER><TABLE CELLPADDING=0, CELLSPACING=15 BGCOLOR=BLUE>"
    goodness +="<CAPTION><ALIGN=TOP><B><U><FONT COLOR=MAROON> SUBJECT / SCORE " +"</FONT></U></B></CAPTION>"
    if(strMath.length==0) {
    strMath=0;
    goodness +="<TR><TD ALIGN=RIGHT><B>MATHEMATICS :<B></TD>" +"<TD><I>" +"ABSENT" +"</I></TD>";

    }
    else{
    goodness +="<TR><TD ALIGN=RIGHT><B>MATHEMATICS <B></TD>" +"<TD><I>" +strMath +"</I></TD>";
    }

    //-------------------validating English values------------------------+

    var fEng=self.opener.document.forms[0].eng.value;
    strEng=fEng.toUpperCase();
    if(strEng.length==0) {
    opener.alert("Please enter score for English");
    }
    if(isNaN(strEng)) {
    opener.alert("Please enter figure for English");
    //strEng="";
    }
    if(strEng.length==0) {
    strEng=0;
    goodness +="<TD ALIGN=RIGHT><B>ENGLISH <B></TD>" +"<TD><I>" +"ABSENT" +"</I></TD></TR>";
    }
    else{
    goodness +="<TD ALIGN=RIGHT><B>ENGLISH <B></TD>" +"<TD><I>" +strEng +"</I></TD></TR>";
    }

    goodness +="</TABLE></CENTER></BODY></HTML><BR></BR>";
    document.myForm.textMe.value = goodness;
    document.myForm.textMe.style.color="red"
    //document.myForm.textMe.style.face="verdana"

    /*var result, nMath, nEng;

    nMath=parseInt(strMath);
    nEng=parseInt(strEng);
    result = nMath+nEng;*/

    }
    </script>
    </head>
    <body onLoad="getIt()">
    <form name="myForm">
    <textarea name="textMe" cols=30 rows=30 readonly></textarea><br>
    <input type="button" name="submit" value="SUBMIT">
    </form>
    </body>
    </html>

    thanks. Please this i need your help for,. When i input data from the first window it appears in the textarea of the second window retrieving the table tags, this is not what i want. i want the the table to come out as a table and the content from the first window to appear in the table, in the textarea of the second window with color blue and font face - lucida console like this:

    MATHEMATICS 60
    ENGLISH 70
    RESULT 130
    Thanks. God bless.

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    HTML can not be displayed in a textarea.

  4. #4
    Join Date
    Mar 2010
    Posts
    2,803
    It sounds like you want the html string coming from window 1 to be rendered in the textarea of window 2. If that's the case then that can be done easily.

    But you can save yourself a lot of work by maybe having a look at the free tinyMCE rich text editor that is a javascript application that can be integrated into your website.

    The 'value' of the textarea in the tinyMCE textarea will be a string of html code, including any styles or formatting you applied to the text. This string can be sent to a server with the rest of the form data and stored in a database or whatever. If you retrieve the string from the db with a php script and assign it to the 'value' attribute of another tinyMCE textarea it will be rendered as html in that textarea.

    You can customise the number and type of tool buttons you allow your users to use in the editor.

    I've used tinyMCE quite a bit as a text editor in forms.

    You can get info and download it from: http://tinymce.moxiecode.com/

    The tinyMCE text editor is similar, if not the same, as the editor you get if using the advanced editing option when making a post here.
    Last edited by tirna; 03-16-2010 at 06:26 AM.

  5. #5
    Join Date
    Jun 2008
    Location
    Europe
    Posts
    1,114

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