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.
index.php
- Code: Select all
<?php include_once('validation.php'); ?>
<html>
<body>
<head><title>Unix Daily Turnover</title></head>
<script>
window.onload = function ()
{
document.getElementById("addButton").onclick = cloneFieldSet;
}
var counter = 0;
function cloneFieldSet ()
{
counter++;
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);
}
</script>
<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>
<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>
</select>
<textarea rows="2" cols="30" name="description_tic"></textarea>
</fieldset>
<input type="button" value="Add" id="addButton" />
<input type="submit" value="submit" name="submit" />
</form>
</body>
</html>
validation.php
- Code: Select all
<?php
date_default_timezone_set('Asia/Calcutta');
$date=date("m/d/Y");
if(isset($_POST['submit']))
{
include("connection.php");
$incidentid=$_POST['incident'];
$severity=$_POST['sev'];
$status =$_POST['status'];
$description_ticket=$_POST['description_tic'];
if(empty($incidentid))
{
echo "<font color=red>";
echo "<br><b>ERROR : </b><br>";
echo "INCIDENT ID IS MISSING";
echo "<br> </font>";
}
if($severity=="none0")
{
echo "<font color=red>";
echo "<br><b>ERROR : </b><br>";
echo "sample value IS MISSING";
echo "<br> </font>";
}
if($status=="none")
{
echo "<font color=red>";
echo "<br><b>ERROR : </b><br>";
echo "STATUS IS MISSING";
echo "<br> </font>";
}
else
{
$sql = mysql_query("INSERT INTO turnovers (DATE,INCIDENTID,SEVERITY,STATUS,TICKETDES) VALUES
('$date','$incidentid','$severity','$status','$description_ticket')") or die ("Database Connection Error" .mysql_error());
if($sql)
{
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 .
Regards


