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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:48:54+00:00 2026-05-23T08:48:54+00:00

Ugh! Any ideas? Have a form which tracks user activity for given time intervals.

  • 0

Ugh! Any ideas?

Have a form which tracks user activity for given time intervals. Each time interval can have inputs for “location” & multiple “activities”. So the form has a variable number of time intervals and a variable number of activities per interval.

How can I set this up in HTML for smooth processing PHP? EDIT: Additional intervals and activities can be added via jQuery.

My initial thought is convoluted so anyone have a better idea?

<!--Interval 1 with 4 activities-->
<input type="text" name="interval[]" />
  <input type="text" name="location[]" />

  <input type="text" name="activity[]" />
  <input type="text" name="activity[]" />
  <input type="text" name="activity[]" />
  <input type="text" name="activity[]" />

<!--Interval 2 with 2 activities-->
<input type="text" name="interval[]" />
  <input type="text" name="location[]" />

  <input type="text" name="activity[]" />
  <input type="text" name="activity[]" />

This is a nightmare on the server side.

  • 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-23T08:48:55+00:00Added an answer on May 23, 2026 at 8:48 am

    You may need to isolate activities per location / interval. A solution would be to use an index for each interval, this involve to change the way you create the new html elements for each interval.

    So the resulting code would be :

    <!--Interval 1 with 4 activities-->
    <input type="text" name="interval[1][]" />
      <input type="text" name="location[1][]" />
    
      <input type="text" name="activity[1][]" />
      <input type="text" name="activity[1][]" />
      <input type="text" name="activity[1][]" />
      <input type="text" name="activity[1][]" />
    
    <!--Interval 2 with 2 activities-->
    <input type="text" name="interval[2][]" />
      <input type="text" name="location[2][]" />
    
      <input type="text" name="activity[2][]" />
      <input type="text" name="activity[2][]" />
    

    But it’s not as smooth to manipulate as :

    <!--Interval 1 with 4 activities-->
    <input type="text" name="interval[1][interval]" value="interval id" />  // optional
    <input type="text" name="interval[1][location]" value="location" />
    <input type="text" name="interval[1][activity][]" value="activity" />
    <input type="text" name="interval[1][activity][]" value="activity" />
    <input type="text" name="interval[1][activity][]" value="activity" />
    <input type="text" name="interval[1][activity][]" value="activity" />
    
    <!--Interval 2 with 2 activities-->
    <input type="text" name="interval[2][interval]" value="interval id" />  // optional
    <input type="text" name="interval[2][location]" value="location" />
    <input type="text" name="interval[2][activity][]" value="activity" />
    <input type="text" name="interval[2][activity][]" value="activity" />
    

    Which will give you a nice tree ( in the form of arrays of arrays ) to iterate over.

    In order to do that, you need a javascript function that keep a track of the current interval index ans use that index to order the array of intervals.

    Server side all you have to do is ( in case of POST method ) :

    foreach ( $_POST['interval'] as $k => $interval ) {
    
        echo $interval['interval'];
        echo $interval['location'];
        foreach ( $interval['activity'] as $id => $activity )
            echo $activity;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ugh ok I'm terrible at explaining things, so I'll just give you the quotes
We've got two developers on the same closed (ugh, stupid gov) network, Another developer
I have for the most part successfully embedded firefox/xulrunner into our c# application, but
I have a validation script that absolutely positions a series of <span> s using
I'm just starting to work on a logging library that everyone can use to
I'm building a framework, which aims to provide a new development environment for the
I've noticed that Magento keeps the URL to the logo it uses for each
I'm trying to help out a nonprofit by doing their website. They want (ugh)
I have a dialog with a number of Alt-Letter shortcuts on labels for textboxes/etc.
With StompChicken's corrections (I miscomputed one dot product, ugh!) the answer appears to be

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.