Not to sure what to do say but here it goes. I am trying to test when a certain part of my page is in focus to display a message box. Here is the page Click Here.
I would like this code to running at all times when on this page.

if(Element.tabIndex = 27)
{
    if(document.getElementById("entry_53").value > 30)
    {
        var ade = document.getElementById("entry_53").value - 30;
        alert( "Please Deposit " + ade);
    }
}

What this code is suppost to do is when the table Amount in Deposit Envelope is in focus or the cursor is in the first box of that table a message box pops up telling the user what the total of that table is supposed to be. If there is a better way to do this I would be grateful for your help thank you.

Hmm... To keep running a script behind (using observefield of ajax) is OK but I would rather run a script when an event is fired. What I would do instead is to add onchange() or onfocus() event to all of the input fields and whatever in each function may be differ depending on what you want.

<script type='text/javascript'>
function whoop(){
 if(document.getElementById("entry_53").value > 30) {
   var ade = document.getElementById("entry_53").value - 30;
   alert( "Please Deposit " + ade); 
   }}
</script>


<input tabindex='27' onfocus='whoop();' onblur='whoop();' id="27" name="27">

I have tried it with onFocus but user is unable to do anything because the message box keeps popping up when the first box is in focus. Is there another way to work around this?

Do not use onfocus() or onblur() to do so if you have to work with multiple boxes because it will be very tricky and give you a lot of headache. Google on "observefield" functionality... Still, I would prefer to use onchange but that's your choice.

I am currently using onchange and will look into observefield thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.