SitePoint Sponsor

User Tag List

Results 1 to 23 of 23

Thread: any ideas?

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    any ideas?

    Unable to get property 'value' of undefined or null reference

    does anyone know what above msg mean and how to fix it?

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    It means you are asking for the value of something that doesn't exist.
    Can you post the script? Is it Javascript?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    function navigate_records(text)
    {

    switch (text)
    {
    case 0:
    document.selection.next.value = parseInt(0);
    break;
    case 1:
    document.selection.next.value = parseInt(document.selection.next.value) + 15;

    break;
    case 2:
    if(parseInt(document.selection.next.value)!= 0)
    { document.selection.next.value = parseInt(document.selection.next.value) - 15;}
    break;
    case 3:
    document.selection.next.value = parseInt(counter);
    break;
    default:
    }
    testingvalidation(0);
    }

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    probably comes on the document.selection.next.value = parseInt(document.selection.next.value) + 15; line as you are not checking if it exists before asking for the value.
    If you look at case 2 in your switch, you have an if statement. Add a similar one to the case 1 part.

    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I will try that now and will let you know. thanks.

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    still getting same error.

  7. #7
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    Can you link to a page where we can see the error, or post enough code here (e.g. the appropriate HTML) that we can recreate your error.

    If you do the latter, you could use this template:

    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    	
    <style>
    
    your CSS here
    
    </style>
    	
    </head>
    <body>
    
    your HTML here
    
    </body>
    
    <script>
    
    your JS here
    
    </script
    </html>

  8. #8
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">

    <style>

    your CSS here

    </style>

    </head>
    <body>

    <a onclick="navigate_records(0); return(false);" href="#">First</a>|<a onclick="navigate_records(1); return(false);" href="#">Next</a>|<a onclick="navigate_records(2); return(false);" href="#">Previous</a>|<a onclick="navigate_records(3); return(false);" href="#">Last</a

    </body>

    <script>

    function navigate_records(text)
    {

    switch (text){

    case 0:

    console.log('first page');
    document.selection.next.length;
    break;



    case 1:
    console.log('second page');
    document.selection.next.value = parseInt(document.selection.next.value) + 15;
    break;

    case 2:
    if(parseInt(document.selection.next.value)!= 0)
    { document.selection.next.value = parseInt(document.selection.next.value) - 15;}
    break;

    case 3:
    document.selection.next.value = parseInt(counter);
    break;

    default:
    }
    testingvalidation(0);
    }


    </script
    </html>

  9. #9
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Ah ok.

    document.selection doesn't have (AFAIK) a next attribute. That's why it's returning undefined.
    Also, I'm not sure how widely supported document.selection actually is.
    I just tested it in Chrom, FireFox and IE and it only works in IE.

    Depending on what you are doing, you should probably use window.getSelection(), which is the most cross-browser compatible.

  10. #10
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works on IE6 - IE8 but not on IE9 and IE10.
    what is your suggestion i should do to solve this problem?

  11. #11
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by joeboo View Post
    what is your suggestion i should do to solve this problem?
    It depends.
    What are you trying to do?

  12. #12
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im trying to get the next 15 record when a link is clicked.

  13. #13
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    OK, the next 15 records from where?
    From a database?

  14. #14
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes.

  15. #15
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Being a client-side scripting language JavaScript is not in a position to perform database operations per se.
    One way of acheiving this is from your JavaScript, to submit an AJAX request to a PHP script, have the PHP script fetch the records from the DB, then return them (e.g. as JSON) so that your JavaScript insert them into the page.

    BTW, I'm curious.
    Knowing now what you are trying to do, what do you mean "it works on IE6 - IE8"?

  16. #16
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the javascript that I mentioned on here earlier seems to be working ok in ie6 - ie8, but when tested in ie9 above all i get is this message "Error: Unable to get property 'value' of undefined or null reference"

  17. #17
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I think we're getting our wires crossed.
    You can't fetch records from a DB using document.selection

  18. #18
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry if i confused you. i'm fetching records from DB using asp.vbscript and display them only the first 15 records at the time.
    the function above is using to shows our next 15 of records and so on...

  19. #19
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Ah ok, that makes much more sense

    So where are the records stored as far as JavaScript is concerned?

  20. #20
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what do you mean? their stored in mysql.

  21. #21
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    So you're fetching them from MySQL using asp.vbscript and then what?
    Inserting them into the page?

    I'm still missing something.
    I don't see how this relates to the earlier code you posted.

  22. #22
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes

  23. #23
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,858
    Mentioned
    206 Post(s)
    Tagged
    12 Thread(s)
    Are you inserting all of the records into the page at once and wanting to use JS to show fifteen at a time?


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
  •