Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Joel Ogbueli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please
Can I send my script for U to see exactly what I mean
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic