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

  • SEARCH
  • Home
  • 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 347319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:15:34+00:00 2026-05-12T11:15:34+00:00

…meaning pattern in its general English usage, not specific to OO design patterns. Given

  • 0

…meaning pattern in its general English usage, not specific to OO design patterns. Given a table like the following (using <% %> as generic server-side script tags):

<form action="someUri" method="post">
<table>
    <thead>
        <tr>
            <td>Widget ID</td>
            <td>Description</td>
            <td>Price</td>
        </tr>
    </thead>
    <tbody>
    <% foreach widget in widgets %>
        <tr>
            <td>
                <!-- input ids need to be mangled
                        to preserve uniqueness -->
                <input type="hidden" id="[Some_Mangled_Input_Id]" 
                    value="<%= widget.Id %>" />
                <%= widget.Id %>
            </td>
            <td>
                <!-- prefill if exists for widget -->
                <input type="text" id="[Some_Mangled_Input_Id]"
                    value="<%= widget.Description %>" />
            </td>
            <td>
                <!-- prefill if exists for widget -->
                <input type="text" id="[Some_Mangled_Input_Id]"
                    value="<%= widget.Price %>" />
            </td>
        </tr>
    <% end foreach %>
    </tbody>
</table>

<input type="submit" value="Save Changes" />
</form>

And on the server at post:

    var widgetIdKeys = all keys in forms collection matching
        pattern of mangled input Id for Widget.Id hidden input

    foreach widgetIdKey in widgetIdKeys

        find matching mangled input Id for Widget.Description text input

        find matching mangled input Id for Widget.Price text input

        if input changed per comparison to some original

            persist Description and Price input for current widget Id

        end if

    end foreach

This problem has no doubt been solved for a long time but this is the only approach I can think of and it seems hacky. So my question is: is there a better pattern and if so what does it look like? If this is the only or preferred way to do this, are there right and wrong ways to handle the input Id mangling and parsing? What about the comparison to identify which inputs have changed? I can think of ways to solve this on a per row or per cell level, and maybe those ways exist because there is no good way to solve it on a per table level, but I can also think of downsides to those ways.

Or am I missing the appropiate paradigm altogether? Thanks for any insights.

  • 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-05-12T11:15:35+00:00Added an answer on May 12, 2026 at 11:15 am

    You might want to use name instead of id for your inputs.

    http://www.mail-archive.com/wsg@webstandardsgroup.org/msg27766.html

    Name and ID serve two different purposes. ID is used to identify the
    element’s node in the document. Name is used to identify the element’s
    value in the form submission posted back to the server.


    You could simplify things by using an arrays for your input names:

    <% for (i=0; i<n; i++) { %>
    <input type="hidden" name="id[i]" />
    <input type="text" name="description[i]" />
    <% } %>
    

    Then on the backend the inputs would all be nicely arranged in arrays (at least in PHP).

    More here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 447k
  • Answers 447k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think is just a matter of sending an email… May 15, 2026 at 7:27 pm
  • Editorial Team
    Editorial Team added an answer You get an int and a function int*int -> 'a… May 15, 2026 at 7:27 pm
  • Editorial Team
    Editorial Team added an answer As I understand it, the only way you can truly… May 15, 2026 at 7:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.