Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


JavaScript Array Passing

Hey all....

I am trying to pass an array to a function and then output its contents, but I keep getting the term [object] when the array is outputted.

Essentially, i want to take an array of input, and pass that info to another function for processing.

heres the code:

var boxVal = new Array()

function findBoxes(){
var numOfBoxes = ""

numOfBoxes = document.forms.SearchQuery.Field.length //how many checkboxes do we have? ***1**
alert("Num of total Boxes is " + numOfBoxes)

for (i = 0; i < numOfBoxes; i++) { //keep counting to get all the boxes
if( document.forms.SearchQuery.Field[i].checked) { //but only find the boxes that are checked ***2**
boxVal[i]= document.forms.SearchQuery.Field[i].value + " " //set boxVal to the val of the checked box it found
alert("Checked Boxes are " + boxVal[i]) //Get the values
} }
return boxVal

function checkedBoxes(boxVal) {//
//boxVal == Array of selected fields returned from findBoxes()

if (boxVal == document.forms.SearchQuery.Field.value)
{ document.forms.SearchQuery.Field.checked = true }
{ document.forms.SearchQuery.Field.checked = false } //end loop

} //End Function

Any suggestions?

Sign In or Register to comment.