I have an HTML form which posts its information to a java servlet. One of the sections in the HTML is a multiple checkbox where one of the options is an “all of the above” option.
Mode of Transportation:<br>
<input type="checkbox" name="transport" value="Car" /> Car <br>
<input type="checkbox" name="transport" value="Bike" /> Bike <br>
<input type="checkbox" name="transport" value="Public Transit" /> Public Transit <br>
<input type="checkbox" name="transport" value="All of the Above" /> All of the Above <br>
The java page accepts it into an array:
String[] transport = request.getParameterValues("transport");
And now it’s supposed to just post back the information: How do I account for the “All of the Above” option? Meaning if it’s checked how do I forgo the other checks and list everything?
Two ways:
Either using
javascript, check all the check boxes ifAll Of the aboveis selected immediately after select or before posting the form.Or handle in the server side i.e. before processing, check, if one of the values is
All Of the abovethen handle it appropriately i.e. populate your user answer list with all options provided.You use statement below to check if
All Of the abovewas selected: