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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:12:31+00:00 2026-05-30T22:12:31+00:00

What i want to do is each time user clicks the button Add and

  • 0

What i want to do is each time user clicks the button Add and calls the addRow function i will also call row_counter function to set the value of the hidden input type field equal to the number of dynamic rows tha have been created. so if i have dynamicly created 3 rows the hidden input type field must be 3. I am new to javascript so please be patient.

<?php 
// Parse the form data and add inventory item to the system
if (isset($_POST['product_name'])) {

    $product_name = mysql_real_escape_string($_POST['product_name']);
    $price = mysql_real_escape_string($_POST['counter']);
    $details = mysql_real_escape_string($_POST['details']); 
    $category = mysql_real_escape_string($_POST['category_choice']);
    $condition= mysql_real_escape_string($_POST['condition']);;
    $supplier_choice= mysql_real_escape_string($_POST['supplier_choice']);;

    // See if that product name is an identical match to another product in the system
    $sql = mysql_query("SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");
    $productMatch = mysql_num_rows($sql); // count the output amount
    if ($productMatch > 0) {
        echo 'Sorry you tried to place a duplicate "Product Name" into the system, <a href="inventory_list.php">click here</a>';
        exit();
    }
    // Add this product into the database now
    $sql = mysql_query("INSERT INTO products (product_name, price, details, category, active, supplier, date_added) 
        VALUES('$product_name','$price','$details','$category','$condition','$supplier_choice',now())") or die (mysql_error());


     $pid = mysql_insert_id();
    // Place image in the folder 
    $newname = "$pid.jpg";
    move_uploaded_file( $_FILES['my_photo']['tmp_name'], "../inventory_images/$newname");
    //ean den yperxan oi 2 epomenes grammes ean ekana refresh tha prospathouse na perasei to idio proion ksana!!
    header("location: inventory_list.php"); 
    exit();

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Inventory Area</title>

<link rel="stylesheet" href="../style/style.css" type="text/css" media="screen"/>

<SCRIPT language="javascript">
    //Add Information
    i=1;
    function addRow(tableID,counter1) {
        //The rows num starts from 0
        var table = document.getElementById(tableID);

        var rowCount = 7;
        var row = table.insertRow(rowCount);

         var cell1 = row.insertCell(0);

        var cell2 = row.insertCell(1);
        var element = document.createElement("input");
        element.type = "text";
        element.name = "information_" + i;
        element.id = "information_" + i;
        element.size = 84;
        cell2.appendChild(element);
        i++;
        row_counter_inc(counter1);
    }

    function deleteRow(tableID) {
        if(i>=2){
            var table = document.getElementById(tableID);
            table.deleteRow(i+5);
            i--;
        }
    }
    function row_counter_inc(counter2){
        w=i;
        w=w-1
        document.getElementByID("counter2").value=w;
    }

</SCRIPT>

<div align="center" id="mainWrapper"> 

  <?php include_once("template_header.php");?>

  <div id="pageContent">

        <div align="left" style="margin-left:24px">
            <h2>Inventory List</h2>
            <?php echo $productList ?>
        </div>

  </div>

  <div>

        <form action="inventory_list.php" enctype="multipart/form-data" name="my_Form" id="my_Form" method="post">

        <a name="add_New_Product_Form" id="add_New_Product_Form">

            <h2>Add New Product Form</h2>

        </a>

        <table width="80%" border="0" cellspacing="0" cellpadding="6" id="dataTable">

            <tr>

                <td>Όνομα</td>
                <td>

                    <label>

                        <input name="product_name" type="text" id="product_name" size="80" />


                    </label>

                </td>

            </tr>

            <tr>

                <td>Κατάσταση</td>
                <td>

                    <label>

                        <input type="radio" name="condition" value="1"> Ενεργό</input>
                        <input type="radio" name="condition" value="0"> Ανενεργό</input>

                    </label>

                </td>

            </tr>


            <tr>

                <td>Τιμή</td>
                <td>

                    <label>

                        <input name="price" type="text" id="price" size="20" />

                    </label>

                </td>

            </tr>

            <tr>

                <td>Προμηθευτές</td>
                <td>

                    <?php echo $suppliers_list; ?>

                </td>

            </tr>

            <tr>

                <td>Κατηγορία</td>
                <td>

                    <?php echo $category_list; ?>

                </td>

            </tr>

            <tr>

                <td>Περιγραφή</td>
                <td>

                    <label>

                        <textarea name="details" id="details" cols="64" rows="5"></textarea>

                    </label>

                </td>

            </tr>

            <tr>

                <td>Τεχνικά Χαρακτηριστικά</td>
                <td>

                    <input type="text" name="information_0" id="information_0" size="84"/>

                </td>

            </tr>

            <tr>

                <td></td>
                <td>

                    <input type="hidden" name="counter" id="counter"/>
                    <INPUT type="button" value="Προσθήκη" onClick="addRow('dataTable','counter')"/>
                    <INPUT type="button" value="Αφαίρεση" onClick="deleteRow('dataTable')"/>

                </td>

            </tr>

            <tr>

                <td>Φωτογραφία</td>
                <td>

                    <label>

                        <input type="file" name="my_photo" id="my_photo"/>

                    </label>

                </td>

            </tr>

            <tr>

                <td>&nbsp;</td>
                <td>

                    <label>

                        <input type="submit" name="button" id="button" value="Αποθήκευση" />

                    </label>

                </td>

            </tr>

        </table>

        </form>



  </div>

   <br /><br />

  <?php include_once("../template_footer.php");?>

</div>

enter code here
  • 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-30T22:12:33+00:00Added an answer on May 30, 2026 at 10:12 pm

    This should work for you:

     document.getElementById("counter").value = 3;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to output the function name each time it is called, I can
I want to be able to automatically publish to a local folder each time
I want to write tests for my app, though each time I look at
I need execute some code before Windows shutdown process each time. So, I want
I want to add a debounce to a button, but i want to perform
I have a button on my home screen that will add an edit text
VB 2008. I have several text boxes on a form and I want each
I have many items inside a list control. I want each item to have
How can i concate this string in mysql desc=desc+$desct what i want is each
I want to process each source code file after it has been preprocessed: myprocess

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.