473,326 Members | 2,196 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,326 software developers and data experts.

how can a function just stop working?

110 100+
I am creating a website that will allow retail insurance agents to enter enough information on a commercial truck to get a quote. I have a function called "item" that validifies the data entered into a text field. It has worked for 6 months; but, now it has quit working. However if I change the name from "item" to "bozo" it works. What gives here?

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="modelYear1" id="modelYear1" disabled="disabled" onFocus="yellowOn('modelYear1'); this.select()" onBlur="yellowOff('modelYear1'); item(1,1)" size="4" style="border: 1px solid #C0C0C0; font-family:Arial Narrow; font-size:10pt; color:#000080; font-weight:bold" maxlength="4" tabindex="2">
  2.  
  3. function item(itemCode,unitCode,optionCode){ 
  4.     var i=itemCode;
  5.     var u=unitCode;
  6.     var o=optionCode;    
  7.     /*
  8.        item 1=model
  9.        item 2=body type
  10.        item 3=GVW
  11.        item 4=make
  12.        item 5=alt make
  13.        item 6=value
  14.     */
  15.  
  16.     if(i==1){// modelYear
  17.         var modelYear;
  18.         modelYear=document.getElementById('modelYear'+u).value;
  19.         // if entry is blank
  20.         if(document.captureEvents && Event.KEYUP) { 
  21.             document.captureEvents(Event.KEYUP); 
  22.             }
  23.  
  24.         if(modelYear!=""&&modelYear!=null){
  25.             var vObject;
  26.             vObject = 'modelYear'+u; //document.getElementById('modelYear'+u).value; 
  27.             if(document.getElementById(vObject).value==""){
  28.                 //document.getElementById(vObject).style.border="1px solid #FF0000";
  29.                 document.getElementById(vObject).style.backgroundColor="#FFFFFF";
  30.  
  31.             } else {
  32.                 document.getElementById(vObject).style.border="1px solid #C0C0C0";
  33.                 document.getElementById(vObject).style.backgroundColor="#FFFFFF";
  34.             }
  35.             // if the entry does not contain only digits
  36.             if(/^\d{4}$/.test(modelYear)!=true){
  37.                 alert("You have entered an invalid year.  Please enter this vehicle's model year");
  38.                 document.getElementById('modelYear'+u).focus()
  39.                 modelYear=modelYear.replace(/^\d+$/,""); // remove all non-numeric characters
  40.             }    
  41.             // is this a valid year?    
  42.             var d=new Date();
  43.             var    thisYear=d.getYear();    
  44.             if(modelYear >thisYear+1||modelYear<=thisYear-15){
  45.                 alert("You have entered an invalid year.  Please enter this vehicle's model year");
  46.                 modelYear="";
  47.                 document.getElementById('modelYear'+u).focus()
  48.             }
  49.         }
  50.         document.getElementById('model'+u).value=modelYear;         document.getElementById('modelYear'+u).value=modelYear;
  51.     }
  52. }
There are other options; but, I have them commented out for now. This is all that's running.
Sep 4 '09 #1
2 1909
Dormilich
8,658 Expert Mod 8TB
all I can think of is a name conflict (there may be another function with that name). besides that there is also a method called item() in JS.
Sep 4 '09 #2
sumittyagi
202 Expert 100+
I agree with Dormilich, I faced the same problem with another name conflict. So always use variable names that do not conflict any predefined js functions or variables.
Sep 4 '09 #3

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

Similar topics

12
by: Surya Kiran | last post by:
Hi all, I've written a function template. say template <class T> fn (T var) { ... } Is there any way, from within the function, can we check what type of argument we've passed on to the...
2
by: Chris Michael | last post by:
Hello everybody, Newbie here. I've been working on this for the last two days and I can't figure out where this problem is. I think it's something so obvious, but I can't see it! OK, firstly...
7
by: deko | last post by:
I have a function with a number of long loops. While the function is running, I want to be able to click a Stop button and exit the function as quickly as possible. The abbreviated code looks...
5
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
26
by: Ricardo | last post by:
I made a program that generate random numbers and put it in a listbox when the user click go. The problem is: how can i made a button stop, to stop the method that is running??? s...
2
by: Maxwell_Smart | last post by:
Is there a way for a function to refer to itself generically? I'd like to use such a thing (should it exist) for convenience and consistency, not functionality. For example: Function...
17
by: DanielJohnson | last post by:
how to use the combination function in python ? For example 9 choose 2 (written as 9C2) = 9!/7!*2!=36 Please help, I couldnt find the function through help.
2
by: Bruno Rafael Moreira de Barros | last post by:
index.php --- inlcude 'application.php'; functions.php --- function test1() { trigger_error('My error'); return FALSE;
5
by: hurricane_number_one | last post by:
I'm trying to have a class, which uses threads be able to raise events to the form that created it. I've seen solutions around the net for this, but I didn't really like their implementation. ...
14
by: squishywaffle | last post by:
Greetings, I'm trying to wrap a function in a C library as a compiled C Python module. Everything is going great, but I've hit a snag. There's a function in the form of this: First the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.