-3

I'm attempting to write a very basic Sudoku game, and am having issues when it comes to testing the value of the input of each cell. Each cell has the following piece of code attached to it:

<div id="cell1" class="4"><input type="textarea" name="number" onkeypress="sudokuheck()"></div>

Then, I am trying to write a function that tests what's inputted in the Textarea against the Div's class. I know using integers as class names isn't the best idea, but I'm using HTML5, and am just trying to get it to work for now.

So far I've tried:

function sudokuCheck()
{
  var x = document.onkeypress;

  if (x = document.previousSibling.ClassName)
  {
    alert("correct");
  }
  else
  {
    alert("incorrect");
  }
}

However, this just doesn't seem to be working. You guys have any idea how I can go about fixing it?

Thanks

Bic1245
  • 127
  • 1
  • 2
  • 12
  • 1
    There's no such element tag as input with type textarea. Use `` tag. – Jan.J Mar 04 '13 at 20:38
  • What you've tried seems to be random syntax thrown together. I'm certain you've not read any tutorials or documentation that would lead you to believe any of this would be effective. – the system Mar 04 '13 at 20:44

1 Answers1

1

The x = document.keypress is a What are you trying to do? If you are trying to get what key was pressed, that is not how you do it. Look at this question.

There is no type=textarea, it will default to a textbox.

Your if statement is wrong

  • = means store
  • == means compare

JavaScript is case sensitive ClassName !== className.

You really need to code things in parts are try to get one thing at a time. Use the browser's console to debug.

Community
  • 1
  • 1
epascarello
  • 204,599
  • 20
  • 195
  • 236