Question: I'm working on a jsp containing a javascript function :

```
function validerSelection(identifiant, page) {
   var form = ObjectId("profilForm");
   form.elements['checkedLogin'].value = "" + identifiant;
   form.elements['pageListe'].value = "" + page;
   form.method.value = '<bean:message key="button.valid"/>';
   window.location = "/STFPresentation/admin/profilUtilisateurSearch.do?method="
        + form.method.value + "&nom=" + identifiant + "&page=" + page;
}

```

The function worked well but I wanted to add a second parameter (called page). "page" is also a variable of my jsp.

I'm calling the javascript function by clicking on a link like this :

```
<a href="javascript:validerSelection('<core:out value="${item.nom}"/>', '<%=numero_page%>')"><core:out value="${item.nom}" /></a>

```

But nothing happens then. Where is my mistake ?

Many thanks

Answer: 
You should do the treatment yourself, I would use of a customized class. Like :

```
// Use of an array, where you gonna hold the data using describing structure
this.array = [];

// Store values along with the size in Byte
push(value, size) {
  this.array.push({
    size,
    value,
  });
}

// Turn the array into a byte array
getByteArray() {
  // Create a byte array
  return this.array.reduce((tmp, {
    size,
    value,
  }) => {
    // Here you makes multiple insertion in Buffer depending on the size you have

    // For example if you have the value 0 with a size of 4.
    // You make 4 push on the buffer
    tmp.push(...);

    return tmp;
  }, new Buffer());
}

```

---

**EDIT: more explanation**

You have to create a class that will handle the data storage and treatment.

When we are dealing with a data, we store it associated with it's size in Byte.

for example the number `12` in `3` Byte, we gonna store `{ value: 12, size: 3 }`.

When we gonna have to generate the Byte array, we gonna use the size we did store in order to push the correct amount of Byte into the `Buffer` array.

for example the number `12` in `3` Byte.

We gonna store in the Buffer `0`, `0` and `12`.

---

To be clear :

**BEFORE**

```
array.push(12);

new Buffer(array);

```

The buffer read the array, takes `12` and convert it into Byte, so `0x0C`

You end up with `Buffer = [ 0x0C ]`

---

**NOW**

```
array.push({ value: 12, size: 3 });

array.reduce( ...

 // Because we have a size of 3 byte, we push 3 Byte in the buffer

 buffer.push(0);
 buffer.push(0);
 buffer.push(12);

..., new Buffer());

```

You end up with `Buffer = [ 0x00, 0x00, 0x0C ]`
Two bytes(-30-+100) // There is no issue with this value. -30 is es in 8-bit two's complement signed integer so this can be stored in 1 byte. 

Two Bytes(0-300) // can be stored in 2 bytes. Convert number to bits for exp. using (300).toString(2) and store into 2 bytes.