How to add additional data in my JQUERY submit?

前端 未结 3 1559
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-15 14:26

In my razor view, I\'m using a Html.BeginForm. In it I have two elements where when I set clic, should submit the form but I need to add an additional string pa

3条回答
  •  星月不相逢
    2021-01-15 14:58

    Based on your comments, the easiest thing for you to do is make your buttons of type submit and give them a name. If they have a name, the value of the button that is clicked will be sent automatically with the form post, see: sending form's submit button's value?

    Example:

    When the a button is clicked, parameter will be posted with value a. Likewise for b and c. If the none button is clicked, no value will be sent and parameter will be null (shown for demonstration purposes, you may not need this).

    @using (Html.BeginForm("Index", "Quiz", FormMethod.Post, new { id = "form" }))
    {
        ...
    
        
        
        
        
    }
    

提交回复
热议问题