Jump to content

Comp Sci help (HTML and JavaScript)

MoeOriginalG

when you go down to read my code, if you're wondering why it's screwed up, its because we took code from a different website the teacher wrote, and are moulding it to make it do what this website is supposed to do. theres a couple more js files that I did not write that make this website run on chrome, as well as a css file which I did not write.

 

So I have to make a little website that looks like this:

2992ec9b2cede319c8ac0c571a404081.png

The website is supposed to take what you enter into that memo box, and then put it into a table with 3 rows. 

The table will hold this standard:  1       Memo        Priority

and it will look like this when youve entered a memo and a priority number, and then clicked priority and clicked enter memo and priority.

5ad81790bc501a30ccf82334688da672.png

 

my delete button doesn't work and neither does my table. as well that part where it says memo, is supposed to change when i change the selected field to priority, but it doesn't.

 

my code so far:

(html code first)

<!DOCTYPE html>
<html>
<!-- cad = euro bitcoin = pound -->
<head>
  <title>Assignment 2</title>
  <link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css">

  <script src="scripts/jquery-1.8.3.min.js">
  </script>
  <script src="scripts/chromeFileProtocolFix.js"></script>
  <script src="scripts/jquery.mobile-1.3.1.min.js">
  </script>

  <script type='text/javascript' src='scripts/assignment2.js'>
  </script>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

<body>
  <div data-role="page">
    <div style="padding: 20px;">
      <div data-role="fieldcontain">
        <label id="inputLabel">Memo: </label>
        <input type="text" id="memPrio" name="memPrio">
      </div>
      <fieldset data-role="controlgroup">
        <legend>Choose Memo (to write a memo) and Priority (to assign a priority to the memo).</legend>
        <input type="radio" name="units" id="Memo" value="Memo">
        <label for="Memo">Memo</label>
        <input type="radio" name="units" id="Priority" value="Priority" checked="checked">
        <label for="Priority">Priority</label>
      </fieldset>
        <input type="button" onclick="convert()" value="Enter Memo and Priority">
      <p id="answer"></p>

      <div>
        <legend>Enter the number of the row to delete.</legend>
        <input type="number" id="rowNum" name="rowNum">
        <input type="button" onclick="deleteRow()" value="deleteRow">

    </div>
    <table id="myTable">
  <tr>
    <td>Item</td>
    <td>Memo</td>
    <td>Priority</td>
  </tr>
  
</table>
  </div>
</body>

</html>

 

 

java script code 


    
  document.getElementById("Memo").onclick =
    function () {
      setUnits("Memo");
    };
  document.getElementById("Priority").onclick =
    function () {
      setUnits("Priority");
    };

// \--------------------------------------
function myCreateFunction() {
  var table = document.getElementById("myTable");
  var row = table.insertRow(0).onClick(convert());
  var cell1 = row.insertCell(0);
  var cell2 = row.insertCell(1);
  cell1.innerHTML = "NEW CELL1";
  cell2.innerHTML = "NEW CELL2";
}


// \--------------------------------------
function validateAmount() {
    var amountInput = document.getElementById("amount");
    if (amountInput.value < 0) {
        alert('The amount must be non-negative.');
        amountInput.value = "";
    }
}
function deleteRow() {
  document.getElementById("myTable").deleteRow(rowNum);
}
function setUnits(unit) {
  var label = document.getElementById("inputLabel");
  label.innerHTML = unit;
}

function convert() {
  var memPrio = document.getElementById(
    "Memo");
  var amount = document.getElementById(
    "Priority");
  myTable.onclick<tr>
    <td>0+1</td>
    <td>Memo</td>
    <td>Priority</td>
</tr>
}

function convertToPound(amtEuro) {
  var amtPound = amtEuro * POUND_FACTOR;
  document.getElementById("answer").innerHTML = amtEuro + " EURO $ = " 
          + amtPound.toFixed(2) + " POUND";
}

function convertToEuro(amtPound) {
  var amtEuro = amtPound * getEuroFactor();
  document.getElementById("answer").innerHTML = amtPound + " POUND = " 
          + amtEuro.toFixed(2) + " EURO $";
}

function getEuroFactor() {
    return 4776.22;
}

 

thanks in advance

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×