Home > Developer > Scripting > Data Method: setValue
setValue
Sets the value of a scalar data object or item within an array data object.
| Syntax |
| AM_data.setValue(id,value, row_index, col_index) |
| Parameters |
| id | (required). Identifier of the data object. |
| value | (required). String to set the value to. |
| row_index | (optional). Zero based row index of the item within array data object. (default "0") |
| col_index | (optional). Zero based column index of the item within of array data object. (default "0") |
| Example |
| This example demonstrates accessing a scalar data object directly as property of the data scripting object AM_data. The example first sets the value of the scalar data object "did_sometext" to "The quick brown fox". The value of the scalar object "did_sometext" is then presented in an alert message dialog box. Note the use of "alert" assumes this script is part of a HTML resource. |
AM_data.did_sometext = "The quick brown fox";
alert(AM_data.sometext);
|
| Example |
| This example demonstrates working with array data Objects using the data scripting object. |
Assume we have declared an array data Meta Object with a unique identifier of "did_myarray" having the following values. Note the row and column indexes are bolded.
| Row \ Column | 0 | 1 | 2 | 3 |
| 0 | [100 | 200 | 300 | 400] |
| 1 | [500 | 600 | 700 | 800] |
| 2 | [900 | 1000 | 1100 | 1200] |
AM_data.setValue("did_myarray" "999" "0","0"); // this sets the array item at row index 0 and column index 0 to 999. The array would now be:
| Row \ Column | 0 | 1 | 2 | 3 |
| 0 | [999 | 200 | 300 | 400] |
| 1 | [500 | 600 | 700 | 800] |
| 2 | [900 | 1000 | 1100 | 1200] |
|