Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ajax paging causing forms elements to not exist

Status
Not open for further replies.

snowboardr

Programmer
Joined
Feb 22, 2002
Messages
1,401
Location
PH
I am paging records using AJAX, and well when i goto the second page... my form elements don't respond to any functions that work on the first page of the AJAX'd paging, one of the functions i am using is shown below: Is there something I must do to make this work? Its kind of odd...


Code:
// check all mail
function checkall() {
	var cbCollection = document.forms['fmail'].elements['mailchecks'];
	for ( var i = 0; i < cbCollection.length; i++ ) {
		if (cbCollection[i].checked==false) {
		cbCollection[i].checked=true;
		}
	}
}


thanks
 
Yes there is a form I even tried putting the form out side of the ajax on the main page i am calling the ajax from, I also tried putting it in the ajax itself... it doesn't work in Firefox or IE... I outputed a form element to an alert and it said undefined

jason
 
Thanks, i figured it out... after about 4 hours... haha

It was because there was only 1 checkbox on the second page, thus the array didn't work! ... My javascript skills are not so good!

Code:
// check all mail
function checkall() {
    var cbCollection = document.forms['fmail'].elements['mailchecks'];
      if(cbCollection.length) {
            for ( var i = 0; i < cbCollection.length; i++ ) {
                if (cbCollection[i].checked==false) {
                cbCollection[i].checked=true;
                }
            }
      } else {
          cbCollection.checked=true;
      }    
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top