javascript - How to send JSON from a checkbox form -


i coded this, working think there better way this.. have form user can check checkboxes. each checkbox have multiple info want send servlet, thought create manually json...

<input name="warehouse"         value="{ 'version':'<%=b.getversion()%>',                  'product':'<%=b.getproduct()%>',                  'productiondate':'<%=b.getproductiondate()%>',                  'order':'<%=b.getorder()%>'                 }"          type="checkbox"> 

then in servlet, read checkboxes...

 string[] product = request.getparametervalues("warehouse");  

i replace " '

product.replace("'","\"");  

and convert every string in json by:

objectmapper mapper = new objectmapper(); box box = mapper.readvalue(product, box.class); 

is there better way above send these info servlet?


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -