473,387 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

popup alert onchange

5
I have a form with a number of text boxes for prices. I'm trying to write a javascript function that will pop up a alert if the price entered is 0.00. I want to use the onchange event on the text boxes. This is what I wrote so far but I'm totally new to javascript so hopefully my code isn't too horribly wrong.

<script type="text/javascript">

Function CheckZeroValue(x)
{
var y = document.getElementById(x).value

If y == "0.00"{
alert("Are you sure?");
}
}
</script>


<input type="text" id="Price1" onchange=CheckZeroValue(this.id)">

When I run this I get an "object expected" error.

Please help!
- LisaC
Mar 29 '07 #1
8 6634
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. Function CheckZeroValue(x) {
  4. If (x == "0.00") {
  5.     alert("Are you sure?");
  6. }
  7. }
  8. </script>
  9.  
  10.  
  11. <input type="text" id="Price1" onchange=CheckZeroValue(this.value)">
  12.  

this should fix you up.
Mar 29 '07 #2
LisaC
5
Thank you for your reply and your help .. but I'm still getting an Object Expected error. This is the test page I built exactly ..

<html>
<head>

<script type="text/javascript">

function CheckZeroValue(x) {

If (x == "0.00") {
alert("Are you Sure?");
}
}

</script>

</head>
<body>

Price: <input type="text" id="Price1"
onchange="CheckZeroValue(this.value)">



</body>
</html>

I know I'm so close! HELP!!
Mar 29 '07 #3
iam_clint
1,208 Expert 1GB
take the javascript out of the head and put it in the body.,
Mar 29 '07 #4
LisaC
5
Hi again .. I tried that and I still get the error on this line:

Price: <input type="text" name="Price1" id="Price1" onChange="CheckZeroValue(this.value)">

???

Thanks for you help!
Mar 29 '07 #5
the only problem i´ve noticed in your code is the way you wrote "if" ehehe

its written "If" and should be "if"
just fix that and you code will be ok :)
Mar 29 '07 #6
LisaC
5
wow .. can't believe the case sensitivity of javascript! That still didn't fix the error :(
Mar 29 '07 #7
LisaC
5
I can't believe it .. I change Function to function and it works now .. wow .. nothing like wasting an entire day on something so small! Yikes!

Thanks all for your help!
Mar 29 '07 #8
acoder
16,027 Expert Mod 8TB
Changed thread title.
Mar 30 '07 #9

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

Similar topics

1
by: MonkeyBoy | last post by:
I am doing some some HTML manipulation in client-side script (IE5.x and IE6.x browsers only). Something like.. var tmpHTML = oTable.outerHTML // do something to the HTML her oTable.outerHTML =...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
1
by: Ron Brennan | last post by:
I've spent all morning on this and now think there is a (slight?) possiblity that onchange doesn't work for input type="file". Can anybody shed any light on this. The onblur fires just fine. The...
4
by: john woo | last post by:
Hi if there are 3 selections, named location,department,employee, the relationshipe is, in a location there are departments, in a department there are employees, so for a selected location,...
4
by: PH | last post by:
Does anyone know how to have the pop-up javascript alert, Response.Write("<script language=javascript>alert('HEY!');</script>); , pop-up after the page has been posted back? I am pressing a...
4
by: David McNerney | last post by:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1 for MacOSX when I type some text and hit Enter in the following form: <html> <body> <form action="http://example.com"...
13
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
1
by: Jan Doggen | last post by:
Hello all, I have a SELECT like this (the 'alert()s are temporary): <FORM method="POST" action="/scripts/runisa.dll?OVB2.132964:PGSPLITVACAFMELDEN:1095144287.9159" id="hulpform"...
1
by: sachu | last post by:
Hi, I would like to create a pop up something similar to yahoo messenger popup which comes on the right pan of the status bar. This i planned to alert the users via popup when he gets the mail....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.