can't validate columns created using createElement

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: can't validate columns created using createElement

 
0
  #11
Jul 23rd, 2009
No problem bros....

Everybody starts with:

'printf(''Hello World");'

BEST OF LUCK!
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #12
Jul 24th, 2009
another problem

well i am calling these functions on the "onblur event"

now i also want that when the user clicks on submit..
all the functions are called....

so i was writing something like:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. iteration = document.getElementById("no_of_applications").value
  2. for ( i=1;i<iteration;i++)
  3. {
  4. error_appname('application_name'+i,erSpan1)
  5.  
  6. }

doesn't work
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: can't validate columns created using createElement

 
2
  #13
Jul 25th, 2009
This can be done in many ways, but I will tell you easiest way:

Your function error_appname(inputField, erSpan), requires 2 argument, so maintain global arrays for those.

  1. // Global arrays used to hold input fileds and error spans
  2. var inputFieldArray = [];
  3. var erSpanArray = [];
  4.  
  5.  
  6. function addRow()
  7. {
  8. // Some of your code
  9.  
  10. gl.type = 'text';
  11. gl.name = 'application_doj' + iteration;
  12. gl.id = 'application_doj' + iteration;
  13. gl.size = 45;
  14. gl.className='cellData';
  15. gl.style.width='220px'
  16. gl.style.height='17px'
  17. gl.value='mm/dd/yyyy'
  18. // Removed your handlers from here and putted it below
  19. cellLeft.appendChild(gl);
  20. document.getElementById("no_of_applications").value=iteration
  21.  
  22. //Adding span for showing validation error
  23. var erSpan = document.createElement('span');
  24. // Add error span to this cell.
  25. cellLeft.appendChild(erSpan);
  26.  
  27. // Here goes ur handler
  28. gl.onfocus= function() {gl.value=""};
  29. gl.onblur= function() {ValidateForm(erSpan)}; // Passing erSpan, so that we can easily show error message
  30.  
  31. // Push elements in global arrays
  32. inputFieldArray.push(gl);
  33. erSpanArray.push(erSpan);
  34.  
  35. }


Now the function to validate all fields will be:

  1. function validateAll() {
  2. var totalRows = inputFieldArray.length; // OR erSpanArray.length
  3. for(var i = 0; i < totalRows; i++) {
  4. error_appname(inputFieldArray[i], erSpanArray[i]);
  5. }
  6. }
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #14
Jul 26th, 2009
great
simple n elegant...
thanks.......
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #15
Jul 26th, 2009
well if i had a different espan id for every erspan
then y couldn't i call it like :

error_appname('application_name'+i,'erSpan' + i)
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 319
Reputation: Luckychap is on a distinguished road 
Solved Threads: 42
Luckychap's Avatar
Luckychap Luckychap is offline Offline
Posting Whiz

Re: can't validate columns created using createElement

 
0
  #16
Jul 26th, 2009
This may work for you:

  1. var dgebi = document.getElementById;
  2. // This function takes elements not elements id.
  3. error_appname(dgebi ('application_name'+i), dgebi ('erSpan' + i));
When you think you have done a lot, then be ready for YOUR downfall.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #17
Jul 26th, 2009
i'll try both and let u know...

thanks..
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #18
Jul 27th, 2009
great both of them work great

there's one more thing left, with which i'll need your help............
i'll post that soon...
thanks
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 185
Reputation: aashishn86 is an unknown quantity at this point 
Solved Threads: 9
aashishn86's Avatar
aashishn86 aashishn86 is offline Offline
Junior Poster

Re: can't validate columns created using createElement

 
0
  #19
Jul 31st, 2009
hii
had to call some functions using arrays and some by element id
had to decide the loop dynamically........
solved it
thanks for the help............
rEaLITy iS aN iLLUSIOn cAUSED bY lACk oF aLCOHOL....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC