SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Tekdot's Avatar
    Join Date
    Jul 2005
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trouble comparing 2 input's

    I'm having trouble comparing 2 input boxes, using getElementById.

    I have 81 hidden inputs (id's b0 through b80) and 81 input boxes (id's a0-a80). (Its just sudoku, so theres no security threat with them being viewable in the source)

    I'm using this code (ill worry about the for loop later)

    Code:
    var solved = true;
    if(document.getElementById(a0).value !=   document.getElementById(b0).value) {
          solved = false
          alert("not solved"); // debug
    }
    But it doesnt seem to be working. Im getting the error a0 is not defined. I know for sure that I have an input box with id=a0.

    Any ideas?
    Need a large site moved (5 GB +)? I can help, PM me for pricing.
    [PR 4] Large File Hosting Site looking for link trades

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Tekdot,

    Put quotes around it: "a0" because it is a string. You can use single or double quote chars.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,240
    Mentioned
    194 Post(s)
    Tagged
    2 Thread(s)

    ids

    I think the script is wanting the variable a0 to have a value. Try
    HTML Code:
    if(document.getElementById('a0').value !=   document.getElementById('b0').value) {
    EDIT:
    darn 1 finger typing !

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Zealot Tekdot's Avatar
    Join Date
    Jul 2005
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you both! Works like a charm.
    Need a large site moved (5 GB +)? I can help, PM me for pricing.
    [PR 4] Large File Hosting Site looking for link trades


Bookmarks

Posting Permissions

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