0

In my program i am using this jquery plugin to show notifications in the jsp pages.

What i want is to get a value from a html table and display it in the text inside the notification, What i tried is as below

<script type="text/javascript">
            $(document).ready(function() { 
            var table = document.getElementById("item");
            for (var i = 1; i<= table.rows.length; i++) {
               val=table.rows[i].cells[1].innerText;
                    if(table.rows[i].cells[10].innerHTML >= table.rows[i].cells[15].innerHTML)
                        {
                            //alert(val);
                            jNotify(
                            ' Re-order level' ,
                        {
                            autohide:false,
                            TimeShown:3000,
                            HorizontalPosition:'center'
                        });
                        }    
                }
                });
        </script>

the variable val in the code is getting alerted in a message box but not inside the jNotify notification. Please Help.

8
  • jNotify(val, { [...] }); ? Commented Feb 4, 2013 at 11:00
  • @FabrícioMatté - myjqueryplugins.com/jquery-plugin/jnotify Commented Feb 4, 2013 at 11:02
  • Works for me jsfiddle.net/JkYzY @MarcinWolny I meant to OP to try that syntax. Commented Feb 4, 2013 at 11:04
  • are you sure you are using jQuery? Commented Feb 4, 2013 at 11:07
  • @TomSarduy yeah its a jQuery Plugin !! Commented Feb 4, 2013 at 11:11

1 Answer 1

1

If I understood it right:

                    jNotify(
                        ' Re-order level. Cell 15 value: [ '+ val +' ]',
                    {
                        autohide:false,
                        TimeShown:3000,
                        HorizontalPosition:'center'
                    });

will output you something like

Re-order level. Cell 15 value: [ test ]

basically: + character allows you to merge strings. So you can create a notification made of both: text and a variable (or any other value). It also forces a type, avoiding lots of mistakes that relate to objects. If for some reason your val was empty then you'll get

Re-order level. Cell 15 value: [ ]

But if that's the case you need to take a look at selector. As everything else should be working fine.

Also use firebug net panel to see if everything is loaded, then you may try to debug it with firequery and firefinder (these are quite basic to use so I'll skip the explanation).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.