1. array to a string and separated by commas
a, push () to sequentially add elements to the array;
b, join () array into a string, which can take parameters separator, default [,]
<Script type = text / JavaScript> $ (Document) .on ( 'the Click', '.sure', function () { var = []; var = new new Highlights the Array (); // or var highlights = []; $ ( '. Plan IPT-INPUT') each. (function () { IF ($ (the this) .val () = '')! { highlights.push ($ ( the this ) .val ()); } }) ; var = highlights.join ARR ( '&' ); // & ARR is divided string $ ( "# all_plan") Val (ARR);. }) </ Script>
2.c: automatically turn the foreach commas string (note: the foreach not attribute delims ) <C: forEach> can be the default string as a comma-separated set of traversal
<c:forEach items="${materialResource.unit}" var="item">
<option selected value="${item}">${item}</option>
</c:forEach>
The following is the actual c: forTokens principle: <c: forTokens> tag delims taken characters $ {materialResource.unit} to a string of the form: m, m, m3, t
<c:forTokens items="${materialResource.unit}" delims="," var="item">
<option selected value="${item}">${item}</option>
</c:forTokens>
b, join () array into a string, which can take parameters separator, default [,]
<Script type = text / JavaScript> $ (Document) .on ( 'the Click', '.sure', function () { var = []; var = new new Highlights the Array (); // or var highlights = []; $ ( '. Plan IPT-INPUT') each. (function () { IF ($ (the this) .val () = '')! { highlights.push ($ ( the this ) .val ()); } }) ; var = highlights.join ARR ( '&' ); // & ARR is divided string $ ( "# all_plan") Val (ARR);. }) </ Script>
2.c: automatically turn the foreach commas string (note: the foreach not attribute delims ) <C: forEach> can be the default string as a comma-separated set of traversal
<c:forEach items="${materialResource.unit}" var="item">
<option selected value="${item}">${item}</option>
</c:forEach>
而实际是下面的c:forTokens原理:<c:forTokens>标签delims截取字符
${materialResource.unit}为字符串,形如:m,m,m3,t
<c:forTokens items="${materialResource.unit}" delims="," var="item">
<option selected value="${item}">${item}</option>
</c:forTokens>