facing proble with fieldset

General discussions related to php

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 48
Joined: Mon Jun 11, 2012 9:13 am

facing proble with fieldset

Postby Gamers » Mon Feb 11, 2013 12:42 pm

Hi ,

I am in last phase of my project and here i am facing a very annoying problem the problem is regarding with fieldsets, let me explain the scenario.

I have created a page where user have to enter records for its daily activity, records could be one for more than one records, for this i am using JavaScript and the add button to dynamic generate the new row with its element like textbox, dropdownlist, textarea on the page.

Problem=> After insert more than one row on the page i cant be insert all the row data into the mysql table only the first row first row data is insert rest is not but i want user can able to enter all the rows data. Hope you guys understand my problem.

For this i have created two file
index.php => file which hold javascript function and html tags
validation.php=> for mysql querries and validation.


Code: Select all

<?php include_once('validation.php'); ?>

<head><title>Unix Daily Turnover</title></head>

window.onload = function ()
    document.getElementById("addButton").onclick = cloneFieldSet;

var counter = 0;
function cloneFieldSet ()

    var theField = document.getElementById("field");
    var theClone = theField.cloneNode(true);
    var elements = theClone.elements;
    for (var el in elements)
            elements[el].name += counter.toString();

    theClone.id += counter.toString();
    theField.form.insertBefore(theClone, this);



<form action="index.php" method="post">

<fieldset id="field">

    <input type="text" name="incident" />
    <select name="sev">
            <option value="none0"></option>
            <option value="sev1">sev 1</option>
            <option value="sev2">sev 2</option>
            <option value="sev3">sev 3</option>
            <option value="sev4">sev 4</option>
    <select name="status[]">
            <option value="none"></option>
            <option value="sample">sample</option>
            <option value="sample1">sample1</option>
            <option value="sample2">sample2</option>
            <option value="sample3">sample3</option>
            <option value="sample4">sample4</option>
            <option value="sample5">sample5</option>
    <textarea rows="2" cols="30" name="description_tic"></textarea>


<input type="button" value="Add" id="addButton" />
<input type="submit" value="submit" name="submit" />



Code: Select all





      $status =$_POST['status'];


         echo "<font color=red>";
         echo "<br><b>ERROR : </b><br>";   
         echo "INCIDENT ID IS MISSING";
                   echo "<br> </font>";

         echo "<font color=red>";
         echo "<br><b>ERROR : </b><br>";   
         echo "sample value IS MISSING";
                   echo "<br> </font>";


         echo "<font color=red>";
         echo "<br><b>ERROR : </b><br>";   
         echo "STATUS IS MISSING";
                   echo "<br> </font>";


         ('$date','$incidentid','$severity','$status','$description_ticket')") or die ("Database Connection Error" .mysql_error());
            echo "<br><b> <font color='green'>Turnover for $date Submitted Successfully</b></font>";

Please guys help me , if anyone know how could i solve this scenario i will be thanks .


php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: facing proble with fieldset

Postby seandisanti » Thu Feb 14, 2013 1:51 pm

i think the easiest thing to do would be to actually have 2 inputs; one that shows previously added records, and one for adding a single row. so when they add one, it goes to the list of added, and the second field is blanked waiting for next row. you avoid all kind of issues doing it that way, such as having a query fail because of one bad field in one record out of however many they're trying to submit.

Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 4 guests