Hi,

I am encountering a problem.

I am making an array using JAVAScript in a JSP.

<!-- MAKE ARRAY OF COMMODITY VECTOR -->
<script language="Javascript">
<!--
lArCommodity = new Array( <%= (lvCommodity.size()+1) %>);

  lArCommodity[0] = new Array("", "");
  <%
  for (int i=0; i<lvCommodity.size(); i++)
  {
  ComboData lComboData = new ComboData();
  lComboData = (ComboData)lvCommodity.elementAt(i);
  %>
  lArCommodity[<%= (i+1) %>] =
  new Array( "<%= lComboData.ciId %>", "<%= lComboData.csName %>" );
  <%
  }
  %>

The problem I am encountering is, that the values of the array can have
quotes (") in them. This gives a javascript error.
e.g.,
The value of lComboData.csName is Plastic Components"s  in the database
The javascript error is
missing ) after argument list.

  new Array( "20", "Plastic Components"s" );
.......................................^

Can anyone help?  I want it to retain teh double quotes between the two S,
because I am using this array to fill a Choice box and I want the value in
teh drop down to be visible as Plastic Components"s.

function fillCommodityCombo()
{
  lbExists = 0;
  for(i=0; i<lArCommodity.length; i++)
  {
    document.write("<OPTION " );
    if (lArCommodity[i][0] == "<%= lAuditScreenData.ciPrefixid %>")
    {
       document.write(" SELECTED ");
       lbExists = i;
    }
    document.write(" >");
    document.write(lArCommodity[i][1] + "</OPTION>");
  }
  document.frmProcessAuditInfo.txtPrefix.value = lArCommodity[lbExists][0];
}


Regards,
Vibha

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to