wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes checking the existence of a form field b/4 processing javascript function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "checking the existence of a form field b/4 processing javascript function" Watch "checking the existence of a form field b/4 processing javascript function" New topic
Author

checking the existence of a form field b/4 processing javascript function

Joel Ogbueli
Greenhorn

Joined: Aug 24, 2003
Posts: 7
since I am using a dynamic form (with loop).....I need the function to check if the form fields exist on the form b/4 processing the function....and any field name that is not displayed at time, the function will skip that field name and process next field name displayed on the form.
By using any conditional statement. i.e.
function passDate(str) {
if PRE_idTESTDATE_ (element) exist then
document.device.PRE_idTESTDATE_.value = str;
for(i=0; i<document.device.PRE_idTESTDATE_.length; i++){
document.device.PRE_idTESTDATE_[i].value = str;
else
skip and check the next field if it exist
}
if TUE_idTESTDATE_ (element) exist then
document.device.TUE_idTESTDATE_.value = str;
for(i=0; i<document.device.TUE_idTESTDATE_.length; i++){
document.device.TUE_idTESTDATE_[i].value = str;
else
skip and end if
}
}
and so on with the rest of the functions
Here is my function that I am using
function passDate(str) {
document.device.PRE_idTESTDATE_.value = str;
for(i=0; i<document.device.PRE_idTESTDATE_.length; i++){
document.device.PRE_idTESTDATE_[i].value = str;
}
document.device.TUE_idTESTDATE_.value = str;
for(i=0; i<document.device.TUE_idTESTDATE_.length; i++){
document.device.TUE_idTESTDATE_[i].value = str;
}
}
function passTechnicianname(str1){
document.device.PRE_idTECHNICIANNAME_.value = str1;
for(i=0; i<document.device.PRE_idTECHNICIANNAME_.length; i++){
document.device.PRE_idTECHNICIANNAME_[i].value = str1;
}
document.device.TUE_idTECHNICIANNAME_.value = str1;
for(i=0; i<document.device.TUE_idTECHNICIANNAME_.length; i++){
document.device.TUE_idTECHNICIANNAME_[i].value = str1;
}
document.device.SUN_idTECHNICIANNAME_.value = str1;
for(i=0; i<document.device.SUN_idTECHNICIANNAME_.length; i++){
document.device.SUN_idTECHNICIANNAME_[i].value = str1;
}
document.device.MON_idTECHNICIANNAME_.value = str1;
for(i=0; i<document.device.MON_idTECHNICIANNAME_.length; i++){
document.device.MON_idTECHNICIANNAME_[i].value = str1;
}
}
function passMonthyear(str2) {
document.device.PRE_idMONTHYEAR_.value = str2;
for(i=0; i<document.device.PRE_idMONTHYEAR_.length; i++){
document.device.PRE_idMONTHYEAR_[i].value = str2;
}
document.device.TUE_idMONTHYEAR_.value = str2;
for(i=0; i<document.device.TUE_idTECHNICIANNAME_.length; i++){
document.device.TUE_idMONTHYEAR_[i].value = str2;
}
document.device.SUN_idMONTHYEAR_.value = str2;
for(i=0; i<document.device.SUN_idTECHNICIANNAME_.length; i++){
document.device.SUN_idMONTHYEAR_[i].value = str2;
}
document.device.MON_idMONTHYEAR_.value = str2;
for(i=0; i<document.device.MON_idTECHNICIANNAME_.length; i++){
document.device.MON_idMONTHYEAR_[i].value = str2;
}
}
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
look at this post and see if it helps you. It uses the form element array.
http://www.coderanch.com/t/113887/HTML-JavaScript/have-checking-array-input-text
Joel Ogbueli
Greenhorn

Joined: Aug 24, 2003
Posts: 7
Please
Can I send my script for U to see exactly what I mean
 
jQuery in Action, 2nd edition
 
subject: checking the existence of a form field b/4 processing javascript function