943,603 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 23rd, 2009
0

Re: can't validate columns created using createElement

No problem bros....

Everybody starts with:

'printf(''Hello World");'

BEST OF LUCK!
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Jul 24th, 2009
0

Re: can't validate columns created using createElement

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
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 25th, 2009
2

Re: can't validate columns created using createElement

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.

javascript Syntax (Toggle Plain Text)
  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:

javascript Syntax (Toggle Plain Text)
  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. }
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Jul 26th, 2009
0

Re: can't validate columns created using createElement

great
simple n elegant...
thanks.......
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 26th, 2009
0

Re: can't validate columns created using createElement

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)
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 26th, 2009
0

Re: can't validate columns created using createElement

This may work for you:

javascript Syntax (Toggle Plain Text)
  1. var dgebi = document.getElementById;
  2. // This function takes elements not elements id.
  3. error_appname(dgebi ('application_name'+i), dgebi ('erSpan' + i));
Reputation Points: 83
Solved Threads: 61
Posting Pro in Training
Luckychap is offline Offline
442 posts
since Aug 2006
Jul 26th, 2009
0

Re: can't validate columns created using createElement

i'll try both and let u know...

thanks..
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 27th, 2009
0

Re: can't validate columns created using createElement

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
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008
Jul 31st, 2009
0

Re: can't validate columns created using createElement

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............
Reputation Points: 10
Solved Threads: 9
Junior Poster
aashishn86 is offline Offline
184 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: JavaScript onmouseover image gallery
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: How to extract HMTL content through the use of XMLHttpRequest object?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC