Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

JavaScript Array Passing

VoidGMVVoidGMV Posts: 6Member
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 }
else
{ document.forms.SearchQuery.Field.checked = false } //end loop

} //End Function



Any suggestions?


Sign In or Register to comment.