473,513 Members | 2,545 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(document.getElementById('percentagego').v alue);
var val2 = parseInt(document.getElementById('percentagewin'). value);
var ansd = document.getElementById('probability');
ansd.value = Math.round((val1 * val2)/100);
}
</script>

<th class="bodyText" align="right">% Go:&nbsp;&nbsp;</th>
<td class="bodyText" colspan="2"><input type="text" id="percentagego" name="percentagego" value="<?php
if (!empty($percentagego)) {
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"><input type="text" id="percentagewin" name="percentagewin" onBlur="probability()" value="<?php
if (!empty($percentagewin)) {
echo number_format($percentagewin,0);
}?>" maxlength="20" size="17"></td>
</tr>
<tr>
<th class="bodyText" align="right">Probability:&nbsp;&nbsp;</th>
<td class="bodyText" colspan="2"><input type="text" onBlur="probability()" name="probability" id="probability" value="" maxlength="3" size="5"></td>
</tr>[/HTML]
Jun 28 '07 #1
3 2615
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(document.getElementById("ITEM_IN[0][PERCENTAGE_GO]").value);
var val2 = parseInt(document.getElementById("ITEM_IN[0][PERCENTAGE_WIN]").value);
var ansd = document.getElementById("ITEM_IN[0][PROBABILITY]");
ansd.value = Math.round((val1 * 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="probability0()" 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="readonly" onBlur="probability0()" name="ITEM_IN[0][PROBABILITY]" id="ITEM_IN[0][PROBABILITY]"size="5" maxlength="3"value="" /></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
6661
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"...
9
3694
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...
1
11271
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. ...
6
7277
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...
5
3070
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
2433
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...
7
5252
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
2593
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
2753
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"...
0
7270
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...
0
7178
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...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
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...
0
7543
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...
0
3255
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
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...

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.