The logic is: I have several groups of radiobuttons on the view which are responsible for several rating parameters of one company. For example:
<td>
<fieldset class="rating">
<input type="radio" id="param1" name="srating" value="5"/>
<input type="radio" id="param1" name="srating" value="4"/>
<input type="radio" id="param1" name="srating" value="3"/>
<input type="radio" id="param1" name="srating" value="2"/>
<input type="radio" id="param1" name="srating" value="1"/>
</fieldset>
</td>
<td>
<fieldset class="rating">
<input type="radio" id="param2" name="pgrating" value="5"/>
<input type="radio" id="param2" name="pgrating" value="4"/>
<input type="radio" id="param2" name="pgrating" value="3"/>
<input type="radio" id="param2" name="pgrating" value="2"/>
<input type="radio" id="param2" name="pgrating" value="1"/>
</fieldset>
</td>
Then I want to pass checked parameters to the controller method which looks like this
public void SaveRating(int CompanyId, int param1, int param2)
{
// ...
}
So the question is: How to combine all the checked parameters into one method call? I suppose to use jquery or mvc features. Also looking for the most efficient way to do it.
UPDATE Can it be a solution?
@using (Html.BeginForm("SaveRating", "MyController"))
{
<td>
<input style="display:none" name="CompanyID" value="@Model.ID"/>
<fieldset class="rating">
<input type="radio" id="sstar5" name="param1" value="5"/><label class="full" for="sstar5"></label>
<input type="radio" id="sstar4" name="param1" value="4"/><label class="full" for="sstar4"></label>
<input type="radio" id="sstar3" name="param1" value="3"/><label class="full" for="sstar3"></label>
<input type="radio" id="sstar2" name="param1" value="2"/><label class="full" for="sstar2"></label>
<input type="radio" id="sstar1" name="param1" value="1"/><label class="full" for="sstar1"></label>
</fieldset>
</td>
<td>
<fieldset class="rating">
<input type="radio" id="pgstar5" name="param2" value="5"/><label class="full" for="pgstar5"></label>
<input type="radio" id="pgstar4" name="param2" value="4"/><label class="full" for="pgstar4"></label>
<input type="radio" id="pgstar3" name="param2" value="3"/><label class="full" for="pgstar3"></label>
<input type="radio" id="pgstar2" name="param2" value="2"/><label class="full" for="pgstar2"></label>
<input type="radio" id="pgstar1" name="param2" value="1"/><label class="full" for="pgstar1"></label>
</fieldset>
</td>
<input type="submit" value="Save" />
}