By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

Splice Method Question

P: 8
I am trying to save information from a text box if the checkbox is selected. The checkboxes are dynamically created with php from mysql tables, so I don't know the index of the array that I would like to delete. My plan is use javascript to delete the null values from the textboxes so the length of that element will correspond with the length of the checkbox element, but I can't figure out how to use the splice method correctly...
I have this function called with onsubmit...

Expand|Select|Wrap|Line Numbers
  1.    function DoTheCheck(form){
  2.   var i = 0;
  3.   var j = form.elements['programs[]'].length;
  4.   for(i=0;i<j;i++){
  5.   if (form.elements['programs[i]'].value==''){
  6.     form.elements['programs[i]'].splice(form.elements['programs[i]'].value(i,1);
  7.   }
  8.   }
  9.   }
Any help would be greatly appreciated.
Jul 9 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
I don't think you can use the splice method for the form elements array. It's for a normal array.

If you post the HTML, I'd have a better idea what you're trying to do. You may not even need this JavaScript code.
Jul 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.