How to add a hidden field to an option element in javascript
<p>I want to add a hidden field to an option element in javascript but I am just learning and have no clue how to do it. I need the hidden variable because I am adding strings that i derive from an object to the select element, but I need to have the id of those objects so I can retrieve them and recreate the objects later on.</p>

<p>I want to add it to this function:</p>

<pre><code>function receiveAnswer(response) {
  var aSeats = document.getElementById("aSeats");
  while (aSeats.childNodes.length &gt; 0) { // clear it out
    aSeats.removeChild(aSeats.childNodes[0]);
  }
  for (var i = 0; i &lt; response.aSeats.length; i++) { // add the items back in
    var option = aSeats.appendChild(document.createElement("option"));
    option.appendChild(document.createTextNode(response.aSeats[i]));
    option.value = i;

  }
}
</code></pre>

<p>here is the html:</p>

<pre><code>&lt;% Venue v = (Venue)session.getAttribute("currentVenue"); %&gt;
&lt;% List&lt;Conceptual_Package&gt; cpList = Conceptual_PackageDAO.getInstance().getByVenue(v.getId()); %&gt;

What Packages do you want to see?

 &lt;form method="post" action="ttp.actions.Sale3PackAction.action"&gt;
 &lt;select name="packid" id="packid"&gt;
     &lt;% for (Conceptual_Package cp: cpList) { %&gt;
    &lt;option value="&lt;%=cp.getId()%&gt;"&gt;&lt;%=cp.getName1()%&gt;&lt;/option&gt;
    &lt;% } %&gt;


 &lt;/select&gt;

    &lt;input type="button" value="  next  " onclick="getSeats();"/&gt;

    &lt;/form&gt;


&lt;!--new--&gt;


Available Seats:

&lt;div&gt;

&lt;/div&gt;

 &lt;select name="aSeats" size="10" id="aSeats"&gt;
 &lt;/select&gt;


    &lt;input type="button" value="  add  " onclick="addToCart();"/&gt;

    &lt;div&gt;

    &lt;/div&gt;


Selected Seats:
 &lt;form method="post" action="ttp.actions.sale4Action.action"&gt;
     &lt;select name="Seat2" size="10" id="seat2"&gt;

     &lt;/select&gt;

&lt;input type="button" value="  remove  " onclick="removeFromCart();"/&gt;

    &lt;/form&gt;

&lt;div&gt;

&lt;/div&gt;

 &lt;form method="post" action="ttp.actions.finalizeSaleAction.action"&gt;

    &lt;input type="submit" value="  Buy Tickets  "/&gt;

    &lt;/form&gt;
</code></pre>
