Explore BrainMass
Share

Explore BrainMass

    Use HTML and JavaScript to display table from input

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    I did most of the homework part. I need someone to help me to fix it (see attachment for requirements)

    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    document.write("Please Enter items purchased with price of each<br/> Item: Price, Item: Price<br/><br/>");
    document.write("Ex:Bread:2, Milk:7,rice:90 ");

    function split()
    {
    var inputval=document.getElementById("textarea").value;
    var nameArray=inputval.split(":");
    var nameArray=inputval.split(",");

    for(i=0;i<nameArray.length;i++)

    document.write(nameArray[i]+"<br/>");
    document.getElementById("txtarea").value=nameArray.join("n");

    document.write("<table border=1><tr><td>"+i+"</td><td>"+integer[i]+"</td></tr>");
    document.writeln("<table border=1><tr><td>Item</td><td>Price</td></tr>");
    document.write("</table>");

    }

    </script>
    <body>
    <form id="splitform" action="">

    <textarea id="txtarea"rows="13" cols="36"></textarea></p>
    <input type="button" id="buttonsplit" onclick="split()" value="Organize!"/ ></p>

    </body>
    <head>
    <html>

    © BrainMass Inc. brainmass.com October 10, 2019, 8:14 am ad1c9bdddf
    https://brainmass.com/computer-science/html-html5/use-html-javascript-display-table-input-614935

    Attachments

    Solution Preview

    First I cleaned up some erroneous tags (stray p tags and a head tag, etc.). Then I moved the two initial document.write() lines out of the JavaScript and just put them in the HTML since they are static text. Also, I ...

    Solution Summary

    Make a page with HTML and JavaScript that parses user input in a specified format and makes a table of the results. The table will have two columns, one for item and one for price. The final row will display the total price.

    $2.19