0

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.

3
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by jackfusion
0

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.

0
<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">

Edited by almostbob

0

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?

0

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.

Edited by Taywin

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.