473,666 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Onblur does not work

8 New Member
Hi,

I have a javascript function that does a calculation and displays the result in the third function.The function is triggered by onblur function.It does not seem to work in IE nor Firefox.

Please help me.

[HTML]<script>
function probability()
{
var val1 = parseInt(docume nt.getElementBy Id('percentageg o').value);
var val2 = parseInt(docume nt.getElementBy Id('percentagew in').value);
var ansd = document.getEle mentById('proba bility');
ansd.value = Math.round((val 1 * val2)/100);
}
</script>

<th class="bodyText " align="right">% Go:&nbsp;&nbsp; </th>
<td class="bodyText " colspan="2"><in put type="text" id="percentageg o" name="percentag ego" value="<?php
if (!empty($percen tagego)) {
echo number_format($ percentagego,0) ;
}?>" maxlength="20" size="17"></td>
</tr>
<tr>
<th class="bodyText " align="right">% Win:&nbsp;&nbsp ;</th>
<td class="bodyText " colspan="2"><in put type="text" id="percentagew in" name="percentag ewin" onBlur="probabi lity()" value="<?php
if (!empty($percen tagewin)) {
echo number_format($ percentagewin,0 );
}?>" maxlength="20" size="17"></td>
</tr>
<tr>
<th class="bodyText " align="right">P robability:&nbs p;&nbsp;</th>
<td class="bodyText " colspan="2"><in put type="text" onBlur="probabi lity()" name="probabili ty" id="probability " value="" maxlength="3" size="5"></td>
</tr>[/HTML]
Jun 28 '07 #1
3 2620
coolguyraj
8 New Member
Hi,

This code works perfectly in IE but does not work in FireFox.

Also this function requires that the two values to be filled up to calculate the result or else it will display "NaN",How can i avoid displaying "NaN" is there any way i can display a alert saying two values are required?


Could someone please help me to resolve this.

[HTML]<script>
function probability0()
{
var val1 = parseInt(docume nt.getElementBy Id("ITEM_IN[0][PERCENTAGE_GO]").value);
var val2 = parseInt(docume nt.getElementBy Id("ITEM_IN[0][PERCENTAGE_WIN]").value);
var ansd = document.getEle mentById("ITEM_ IN[0][PROBABILITY]");
ansd.value = Math.round((val 1 * val2)/100);
}
</script>

<td class="bodyForm "><input type="text" name="ITEM_IN[0][PERCENTAGE_GO]" id="ITEM_IN[0][PERCENTAGE_GO]"maxlength= "3" size="3" /></td>
<td class="bodyForm "><input type="text" onBlur="probabi lity0()" name="ITEM_IN[0][PERCENTAGE_WIN]" id="ITEM_IN[0][PERCENTAGE_WIN]"maxlength= "3" size="3"
/></td>

<td class="bodyForm ">


<input type="text" id="answer" readonly="reado nly" onBlur="probabi lity0()" name="ITEM_IN[0][PROBABILITY]" id="ITEM_IN[0][PROBABILITY]"size="5" maxlength="3"va lue="" /></td>[/HTML]
Jun 28 '07 #2
acoder
16,027 Recognized Expert Moderator MVP
You're using the same name for the function and the name/id of the text element. Choose a different name for one of the two.
Jun 28 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
I've merged the two threads.

You can use isNaN to check if a value is a number.
Jun 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6666
by: EviL KerneL | last post by:
Hi - I cannot seem to get these two events to work together. If I change them to say onmousedown and onmouseup, they seem to work fine. In this case, the onclick appears to work properly but onblur does not kick in. <a href="javascript:submitCheck();"><img border="0" alt="Next" name="btnNext" src="Resources/SurveyButtons/Next.gif" onclick="this.src='Resources/SurveyButtons/Wait.gif';"
9
3699
by: Roger Withnell | last post by:
Tearing hair out time! Simple attached page shows the problem. http://www.brilley.co.uk/TestFocusSelect.htm Using a function to test if too many characters have been keyed in to a textarea. Obviously, must return focus and select to the textarea if too many have been keyed. When the function is called with onblur, it works in IE but not in Safari or NN. The function is called but the focus() and select() methods fail.
1
11293
by: Christoph | last post by:
I'm trying to validate some HTML form elements when the user tabs out of each element. However, I'm having some problems. It appears that the order of events is onChange followed some time afterwards by onBlur. I believe this to be the case because in my onChange script, if the validation fails, I force focus back to the field element. However, the focus still falls to the next field and not back to the field I tried to force the...
6
7302
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT WinIE6. WinIE6 says there's an error in the code, but the debugging info says the problem is on line 1 char 1, which are comments. <Body bgcolor='black' Text='#dbdbdb' onblur='window.resizeTo(150,150)'
5
3082
by: lindanr | last post by:
In ASP.NET 2005 I have an onblur="window.close()" javascript event in the <body> tag. When I click on the window's scrollbar, the window closes. The same code works fine in ASP.NET 2003. Any ideas?
10
2448
by: John Kotuby | last post by:
Hello all... I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen to use popup windows in some cases because it makes the user experience better (according to all the users I have polled who will be using this app). In an attempt to keep the popup from disappearing behind the calling window, I am adding the onblur="FocusMe():" event to the Body tag of the popup. I really want onblur to react to any click outside...
7
5282
by: laredotornado | last post by:
Hi, Using the onblur handler in a text field, how can I check if the value was changed from what was originally there prior to the user focussing on the text field? Thanks, - Dave
1
2600
by: Duncan | last post by:
Hi all, I'm tearing my hair out on this! I have a simple ASP.NET 2 page with a TextBox control, in the PreRender I set ClientSide events:- Response.Attributes.Add("onchange", "javascript:alert('Changed');"); Response.Attributes.Add("onfocus",
2
2756
by: John Kotuby | last post by:
Hi all, I am integrating some 3rd party grids into a large ASPX form page in VS 2008 using VB. I have 4 different grids on the page. The object is to not allow the user to leave a grid if he/she is in the middle of editing a row and has not selected the button to "save" the changes to the client-mode grid. BTW, none of these "changes" are actually saved to the database until the entire page is posted back (I am not using Callbacks on...
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1772
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.