Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8526033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:09:14+00:00 2026-06-11T08:09:14+00:00

I have an array of anchor tags used to submit the form foreach (var

  • 0

I have an array of anchor tags used to submit the form

foreach (var item in items)
<a  class="submitform" data-did='<%:Model.DID%>'  data-daid='<%:Model.daID%>' href="#"><%:Model.DisplayText%>
</a>

on click of anchor I dynamically attach form to it and populate the hidden fields with data- attributes value which i required on form submission like this

 $(".submitforapproval").click(function (e) {
        e.preventDefault();
        var daid = $(this).data("daid");
        var did = $(this).data("did");

        $("<form/>", { action: "/HOME/PostMethod", method: "POST", id: "temp_form" }).appendTo("body");
        $("<input/>", { class: 'jshiddenInput', type: "hidden", name: "docid", value: did }).appendTo("#temp_form");
        $("<input/>", { class: 'jshiddenInput', type: "hidden", name: "DocAID", value: daid }).appendTo("#temp_form");

        $("#temp_form").submit();


    });

I am trying to develop a server side solution for this. one way i think is to have form wrap around each anchor tag and use two hidden field in each form instead of data- attributes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:09:16+00:00Added an answer on June 11, 2026 at 8:09 am

    Why is all this javascript necessary? Why not use standard HTML forms with submit buttons? It seems semantically more correct:

    <% foreach (var item in items) { %>
        <% using (Html.BeginForm("PostMethod", "Home", FormMethod.Post)) { %>
            <%= Html.TextBox("docid", Model.DID) %>
            <%= Html.TextBox("docAID", Model.daID) %>
    
            <button type="submit">
                <%: Model.DisplayText %>
            </button>
        <% } %>
    <% } %>
    

    and as far as the server side method is concerned, you could have a view model:

    public class DocumentViewModel
    {
        public string DocId { get; set; }
        public string DocAId { get; set; }
    }
    

    and then your POST controller action will simply take this view model as parameter:

    [HttpPost]
    public ActionResult PostMethod(DocumentViewModel model)
    {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array of strings, String[] data and it's 10 elements has value P
I have a while loop which creates a list of anchor tags each with
var linksInCategory = document.id($('.CategoryTreeLabel').href); var randomLinkArray = new Array(linksInCategory); //CategoryTreeLabel is the class all
I have a form that is using an anchor name as it's action so
Folks, I have this array: var list = new Array('Archer','Archer','Banker','Lantern','Toryboy','The Barb','Tim Whiffler','Glencoe','Warrior','Nimblefoot','The Pearl','The Quack','Don
I have checkboxes in my form, which returns me string instead of array, as
So i have a form that used for two functions/conditions : Save(add) and Update
I have a two dimensional array that I need to load data into. I
I have array INPUTFILES with n files INPUTFILES=( file_0 ... files_n-1 ) And i
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.