views:

185

answers:

2

Hi I am new to Netui and Javascript so go easy on me please. I have a form that is populated with container.item data retuned from a database. I am adding a checkbox beside each repeater item returned and I want to add the container item data to an array when one of the checkboxes is checked for future processing.

The old code used Anchor tag to capture the data but that does not work for me.

<!--netui:parameter name="lineupNo" value="{container.item.lineupIdent.lineupNo}" />

here is my checkbox that is a repeater.

<netui:checkBox dataSource="{pageFlow.checkIsSelected}" onClick="checkBoxClicked()" tagId="pceChecked"/>

this is my Javascript function so far but I want to a way to store the container.item.lineupIdent.lineupNo in the array.

function checkBoxClicked()
{
var checkedPce = [];
var elem = document.getElementById("PceList").elements;

for (var i = 0; i < elem.length; i ++)
{
if (elem[i].name == netui_names.pceChecked)
{
if (elem[i].checked == true)
{
//do some code. }
}
}
}

I hope this is enough info for someone to help me. I have searched the web but could not find any examples.

Thanks.

A: 

var checkedPce = new Array();

//some other code

checkedPce[0] = stuff_you_want_to_add
Tom
I need a way to pass the container data to the javascript method and save it in an array.
Rich
A: 

If you merely want to add a value to an array, you can use this code:

var array = [];
array[array.length] = /* your value */;

You may need to use a dictionary approach instead:

var dictionary = {};

function yourCode(element) {
  var item = dictionary[element.id];
  if (item == null) { 
    item = /* create the object */;
    dictionary[element.id] = item;
  }

  // Use the item.
}
John Fisher
I want to call the javascript function when my checkbox is clicked then capture the container.item data associated with the reapter row in an array.
Rich
Then use the "var array = [];" line outside the function, and put the "array[array.length] = /* whatever */;" line inside your function. You may prefer to use a dictionary approach, though. I edited my answer for you.
John Fisher