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 118735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:32:30+00:00 2026-05-11T03:32:30+00:00

I’m working on a web application (with ASP.NET 2.0 (C#) and jQuery) In my

  • 0

I’m working on a web application (with ASP.NET 2.0 (C#) and jQuery)

In my application we have an interface using which our employees are able to enter records of a comany. We provided the interface with basic fields, Company Name, Contact Person, phone, etc. Now as you know some companies have thier branches, some have few (1 to 10) and some have many (100-200) branches. We have also provided a dynamic interface using jQuery, which allows our employees to add branches depending on number of branches a particular company have.

For addition, we have used jQuery’s append function as ..

$('#branches').append('branch html fields text liek a html input field with id 'Namebranch1' '); 

Now, with adding we have also provided a button with evey branch field seprately for deleting that particular branch. For deleting I have used

$('#branch1').remove() 

Let’s say, I have added 5 branches, then before submitting, I feel that branch number 3 is not necessary to enter, So I have deleted that branch data. So the process of adding and removing is as follows, we have added

1,2,3,4,5

Then, We deleted 3rd branch and now we have

1,2,4,5

Now as we have 4 elements, so whenever my user is adding or deleting a branch I am adding 1 and substracting 1 from a javascript variable respectively. And then entering that variable in a hidden field, so that when user submit data then I’ll have the correct number of count that how any branches are added by the user and on the basis of this count, I know that how many times I have to run the loop to catch up all branches data seprately.

But the problem is when user submit the form then I am running a loop 4 times, what it means, I’ll get data of 1,2 and 4 branches but as loop will stop when it completed 4 cycles then, data of 5th branch which is actully 4 will be missing. Because elements which will be posted when user will sibmit form are as (branchName5, branchTitle5 etc.)

I hope you guys understand what I need? Please tell me some logical solution of this problem.

Thanks

  • 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. 2026-05-11T03:32:31+00:00Added an answer on May 11, 2026 at 3:32 am

    Get rid of the hidden counter variable, and just iterate through Request.Form.Keys looking for branch*. Then, you’ll just process any form variables that start with branch.

    class Branch { public string Name; public string Title; }  void OnLoad(EventArgs e) {    base.OnLoad(e);     var branches = new Dictionary<int, Branch>();    foreach (string key in Request.Form.Keys) {      if (!key.StartsWith('branch')) continue;       int id;      if (key.StartsWith('branchTitle')) {        id = int.Parse(key.Substring('branchTitle'.Length));        branches.Ensure(i).Title = Request.Form[key];      } else if (key.StartsWith('branchName')) {        id = int.Parse(key.Substring('branchName'.Length));        branches.Ensure(i).Name = Request.Form[key];      }                } }  // Ensure extension method T Ensure<K, T>(this Dictionary<K, T> d, K key) where T:new {    if (!d.ContainsKey(key)) {       d.Add(key, new T());    }    return d[key]; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.