Splice Method Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fishctr
    New Member
    • Feb 2008
    • 8

    Splice Method Question

    Hello,
    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...

    Code:
       function DoTheCheck(form){
      var i = 0;
      var j = form.elements['programs[]'].length;
      for(i=0;i<j;i++){
      if (form.elements['programs[i]'].value==''){
        form.elements['programs[i]'].splice(form.elements['programs[i]'].value(i,1);
      }
      }
      }
    Any help would be greatly appreciated.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    Working...