473,386 Members | 1,712 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,386 software developers and data experts.

Rewriting form element that has wrong data type entered

1
Hi, I have searched for several days to try to resolve my little problem.Sorry but I have very little experience with JavaScript OOP.

I have a form which consists of at least one line.

Each line of the form includes the numeric variables qty, rate and VAT and a text variable called description.

When the form is first presented to the user it has values in each form element. What I am trying to do is restore the original numeric value in any of the numeric form elements if a non-numeric value has been entered. This I have failed miserably to do. I can save the original numeric value and I can tell which form element I have just come out of but I can't as yet write that stored value back when necessary.

I have attached the bones of my script.

Expand|Select|Wrap|Line Numbers
  1. function SumLine (form, line, focusWhere) {
  2. newValue = tdp(focusWhere.value);
  3. if ( isNaN(newValue) == true) {
  4. alert ("Different types!" + storedValue + focusWhere.name);
  5. form.focusWhere.name = storedValue;
  6. }
  7.  
The alert works as I hoped giving the expected values for storedValue and focusWhere.name but the last line doesn't work (I have also tried form.[focusWhere].name=stored value.

I can use element[] if I could work out the numer of the particular element. Bear in mind that that the form can have one or more lines and so can be of different lengths at different times.
Aug 31 '09 #1
1 1529
RamananKalirajan
608 512MB
Hi will1,
You cant change the Name of a form Element. The code <b>form.[focusWhere].name=storedValue</b> what it will try to do is, it tries to change the name of the form Element focusWhere. If you want to change the value of the form element just replace that line by form.[focusWhere].value=storedValue (or)
focusWhere.value=storedValue; This would do.

Regards
Ramanan Kalirajan
Sep 1 '09 #2

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

Similar topics

10
by: Norman Bird | last post by:
I have a form i will use to register new people and when I click the submit button, the form just shows itself. It is supposed to show a message showing field errors if you leave fields blank etc....
2
by: nntp-service.ohio-state.edu | last post by:
Hey folks - I'm a newbie to java script. I'm trying to make a portable data-validator for fields in an HTML form. Ideally, it would work something like this: <input type="text" name="test"...
4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
4
by: Rick | last post by:
Hello, I'm having trouble with submitting my form when checking to see if data is present in the user-inputted fields. What I want to happen is for the user to input various pieces of data,...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
6
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
1
by: fugaki | last post by:
Hi everyone I'm learning asp, and i downloaded this script to teach me how to post form data from a webpage to an access database. I put it on the server so i could make sure that it worked, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.