Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to generate Mathematical tables with Javascript

    You are required to design a HTML web page which can generate and display simple Mathematical table(s) with the help of JavaScript, by getting input from users.

    1. Create HTML tables, input text fields and submit buttons.
    2. Perform Input text field validation through JavaScript.
    3. Use of if-else and loops in JavaScript.
    4. Create and use functions in JavaScript.
    5. Generate HTML tables dynamically.


    Please read the instructions carefully.
    1. Your assignment must be in HTML format; any other format even simple text files (notepad files) will not be accepted.
    2. Open notepad, write your code in this new file and save it. While it asks for file name, use starting and ending double quotes to save the file in HTML format like “VUID.html”.
    3. Create a function ValidateStartField to validate the start input field. Use onChange event in this function.
    4. Create a function ValidateEndField to validate the end input field. Use onChange event in this function.
    5. Create a function ValidateSizeField to validate the depth/size field. Use onChange event in this function.
    6. Create a function GenerateTables and write the code to generate math tables.
    7. Create a function DisplyTable and write the code to display a math table on HTML page.
    8. To create HTML elements with the help of JavaScript pass HTML code to document.write( ) function as string. For example if you want to create HTML table with the help of JavaScript write
    document.write( “<table border="1"><tr><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td></tr></table>” );
    9. For more details see screen shots.














    I shall be very thankfull to you if you give me solution of this task.
    Regards.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,696
    Thanks
    25
    Thanked 658 Times in 657 Posts
    I don't know if you know how funny this is tigeronline.
    Post your code and we will help you with problems, but if you want someone to write it for Hire a programmer.

  • #3
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by sunfighter View Post
    I don't know if you know how funny this is tigeronline.
    Post your code and we will help you with problems, but if you want someone to write it for Hire a programmer.
    I think several ppl from the same class has posted this same question..lol

    Or possibly the same guy with two different names. The other guy seemed to have some code already though.
    Teed

  • #4
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,747
    Thanks
    22
    Thanked 1,838 Times in 1,822 Posts
    Quote Originally Posted by teedoff View Post
    I think several ppl from the same class has posted this same question..lol
    .
    Hahaha! www.codingforums.com/ is on some bulletin board just down the hall from that class.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #5
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    Excavator,

    You mean like this on a bulletin board?




    Just kidding. If I should take this down, please tell me. Just adding to the light humor.


    --Kevin

    .
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #6
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    please friends help me. i am working on it for 2 days but unable to create this.

  • #7
    Regular Coder Kevin_M_Schafer's Avatar
    Join Date
    Apr 2011
    Location
    Fairfax, Minnesota, U.S.A.
    Posts
    482
    Thanks
    97
    Thanked 17 Times in 17 Posts
    Hi tigeronline,

    Welcome to CodingForums. What you have in mind takes more than html by itself. It's going to take javascript, more likely ajax script.

    May I ask, what did you use to allow you to take screen shots of it? Or are these scans from a book? Perhaps someone here can steer you where you need to find help. I think this would be better posted on the javascript board.

    MOST IMPORTANT: tigeronline, you need to read the Rules & Posting Guidelines. Tip: * You're not supposed to ask for homework help. You could get in trouble with your teacher.

    * Some help here and there would be fine, but not your entire assignment.

    Peace.

    Your friend,
    Kevin

    .
    Last edited by Kevin_M_Schafer; 01-17-2012 at 05:38 PM. Reason: text clarity
    My keyboard is an IBM from 1993 and I like it that way. | Who is Dan Well? Everyone always says I know Dan Well.Building a web page is like building a birdhouse. Put it up there and watch 'em come. | Maintaining the aspect ratio of an image is more important than having a cold orange pop.

  • #8
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by tigeronline View Post
    please friends help me. i am working on it for 2 days but unable to create this.
    tigeronline, you should read the forum rules about posting homework assignments. While asking for help even on homework assignments is ok, you need to show some initiative on trying to code this yourself. Show what you've done coding wise, and explain whats not working about YOUR code.

    In other words, ppl here wont do the work for you.
    Teed

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i done it but tables are not shown as given in asignment.
    please help me regarding this. or if there is any other problem please guide me. r
    egards.
    Here is the coding which i have done.

    <html>
    <head>
    <title></title>
    <script language="javascript" type="text/javascript">
    <!--

    function checkform()
    {
    if(document.computer.saba1.value<1)
    {
    window.alert("Start Text box is empty");
    }

    if(document.computer.saba2.value<1)
    {
    window.alert("End Text box is empty");
    }

    if(document.computer.saba3.value<1)
    {
    window.alert("Depth/Size Text box is empty");
    }

    function GenerateTables(){
    var start = document.tables.start.value;
    var end = document.tables.end.value;
    var size = document.tables.size.value;

    for (start; start <= end; start++) {
    document.write("<table width='100' align='center'>")
    document.write("<caption><b>Table of </b>" + start + "</caption><br>")
    document.write("</table><br>")

    for (var i = 1; i <= size; i++) {

    document.write("<table border=1 align='center'>")
    document.write("<tr height=40 align='center'>")
    document.write("<td width=40 align='center'>" + start + "</td>")
    document.write("<td width=40 align='center'> * </td>")
    document.write("<td width=40 align='center'>" + i + "</td>")
    document.write("<td width=40 align='center'> = </td>")
    document.write("<td width=40 align='center'>" + start * i + "</td>")
    document.write("</tr>")
    document.write("</table>")
    }
    }
    }

    }
    </script>
    </head>
    <body>
    <form name="computer" method="post" action="function GenerateTables()">
    <table border="2">

    <tr>
    <td>Start:</td>
    <td><input type="text" size="25" name="saba1"></input></td>
    </tr>

    <tr>
    <td>End:</td>
    <td><input type="text" size="25" name="saba2"></input></td>
    </tr>

    <tr>
    <td>Depth/Size:</td>
    <td><input type="text" size="25" name="saba3"></input></td>
    </tr>

    <tr>
    <td></td>
    <td><input type="submit" value="GenerateTables" name="saba4" onMouseOver="checkform()"></input></td>
    </tr>

    </table>
    </form>
    </body>
    </html>

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Do please read the posting guidelines as requested.

    When posting here please help us to help you by following the posting guidelines and wrapping your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.

    If I were you I would look at http://www.codingforums.com/showthread.php?t=248891 post #5 for an explanation of why your assignment as specified above is impossible.

    <script language="JavaScript"> is long deprecated and obsolete. Use <script type = "text/javascript"> instead. The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are looking at ancient and perhaps unreliable code.
    Last edited by Philip M; 01-17-2012 at 08:56 AM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #11
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Also document.write became obsolete for use in web pages when Netscape 4 dies (approximately 2005) so any script intended to run in a web page that uses document.write should have been rewritten around 6 or 7 years ago to get rid of thiose statements. The document.write statement only works in certain situations and can easily cause script clashes and broken web pages. The modern replacements can be completely unobtrusive and the page will still work properly with JavaScript disabled.

    If you are interested in how you should be adding tables to HTML from JavaScript then the example that I just uploaded to http://javascriptexample.net/domtable12.php shows you the JavaScript commands needed to add a table into HTML in a completely unobtrusive manner. It doesn't generate the exact multiplication table from the assignment that the various threads here are asking about but the principle is the same - only the number of columns and rows and the table content is different.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #12
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,696
    Thanks
    25
    Thanked 658 Times in 657 Posts
    Some points
    1. Don't use onmouseover for a button. Things went all to hell when I first ran this script. Use onclick. BTW lower case is preferred.
    2. When checking for empty fields with a submit button, use a return so the form don't execute.
    3. You need id's in the text field also so you can use var start = document.getElementById('saba1').value; instead of var start = document.tables.start.value; which is incomplete.

    You have the ending } for your first function in the wrong place.


  •  

    Posting Permissions

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