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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:50:45+00:00 2026-05-13T23:50:45+00:00

I basically need to check if there is an easier way to do this

  • 0

I basically need to check if there is an easier way to do this before I rewrite all the code. I have a fairly large form that I have each input named with []’s on the end so I can loop through via php for easy insertion.

            <input type="hidden" name="currentdate[]" value="<?php echo date('mdY'); ?>">
                <td><input style="width: 50px" type="text" name="jackname[]" /></td>
                <td><input style="width: 20px" type="text" name="jackkey[]" /></td>
                <td><input style="width: 50px" type="text" name="jackbeg[]" /></td>
                <td><input style="width: 50px" type="text" name="jackend[]" /></td>
                <td><input style="width: 50px" type="text" name="jackbegveh" /></td>
                <td><input style="width: 50px" type="text" name="jackbegmon[]" /></td>
                <td><input style="width: 50px" type="text" name="jackendveh" /></td>
                <td><input style="width: 50px" type="text" name="jackendmon[]" /></td>
                <td><input style="width: 50px" type="text" name="jacktx" disabled /></td>

There are quite a few more fields but you get the idea. I then use

foreach ($_POST['jackname'] as $row=>$name) 
{ 
    $jackname = $name;
    $date = $_POST['currentdate'][$row];
    $jackkey = $_POST['jackkey'][$row];
    $jackbeg = $_POST['jackbeg'][$row];
    $jackend = $_POST['jackend'][$row];
    $jackbegveh = $_POST['jackbegveh'][$row];
    $jackbegmon = $_POST['jackbegmon'][$row];
    $jackendveh = $_POST['jackendveh'][$row];
    $jackendmon = $_POST['jackendmon'][$row];
    $jacktx = $_POST['jacktx'][$row];
    if ($jacktx == '') { 
        $jacktx = '0'; 
    }

    if (empty($jackkey)) {
        echo 'Skipped empty! <br />';

    } else {
        mysql_query("INSERT INTO `ticket_counts_jackson` VALUES('', '" . $date . "', '" . $jackname . "', '" . $jackkey . "', '" . $jackbeg . "', '" . $jackend . "', '" . $jackbegveh . "', '" . $jackbegmon . "', '" . $jackendveh . "', '" . $jackendmon . "', '" . $jacktx . "')", $mysql_link) or die(mysql_error()); 
        echo 'Added the info the db! <br />';

    }
} 

I use the above to loop through the form and add it to the database. Now for my main question. I also want to add in some javascript to do a little math. Basically ($jackendveh - $jackbegveh) - ($jackendmon - $jackbegmon) and have that displayed in jacktx. Currently the only way I know of adding in the math calculations is to rename each input to a unique name and then rewrite my insert from 1 insert to 8 inserts.

  • 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-13T23:50:45+00:00Added an answer on May 13, 2026 at 11:50 pm

    I would add an ID to each input field like so

            <td><input id="jackname" style="width: 50px" type="text" name="jackname[]" /></td>
            <td><input id="jackkey" style="width: 20px" type="text" name="jackkey[]" /></td>
            <td><input id="jackbeg" style="width: 50px" type="text" name="jackbeg[]" /></td>
            <td><input id="jackend" style="width: 50px" type="text" name="jackend[]" /></td>
            <td><input id="jackbegveh" style="width: 50px" type="text" name="jackbegveh" /></td>
            <td><input id="jackname" style="width: 50px" type="text" name="jackbegmon[]" /></td>
            <td><input id="jackname" style="width: 50px" type="text" name="jackendveh" /></td>
            <td><input id="jackendmon" style="width: 50px" type="text" name="jackendmon[]" /></td>
            <td><input id="jacktx" style="width: 50px" type="text" name="jacktx" disabled /></td>
    

    and then using jQuery you should be able to do it like so

    $(document).ready(function(){
       $("input").change(function(){
          var value = $("#jackendveh").val() - $("#jackbegveh").val() - $("#jackendmon").val() - $("#jackbegmon").val();
          $("#jacktx").val(value);
       });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I basically need to show a wait window to the user. For this i
I basically need to know how to import SQL code into Access. I've tried
Basically what I need is an automated way to update the product version number
Basically what the title says... I need to have an image that when clicked,
I have one array that contains some settings that looks like basically like this:
Basically I have a main form which upon loading, opens a child form for
I basically need to highlight a particular word in a block of text. For
I want to filter the selectable dates on a datepicker. I basically need to
Basically I need a hosted solution, where one can create an account for a
Basically I need to run the script with paths related to the shell script

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.