Hello Friends,
I am facing a problem of nesting the form tags in html.
A am having two dropdown box.
one for category and other for sub category.
what i am doing is iwant sub category`s as category
So when category is changed form is submited so that selected category can be identified. and form is submited on the same page. and all work is done on submitting page is submitted on otherpage
so please help to do these.
here is the link
[url]http://www.myshadi.com/drug/addproduct.php
here is the code.
[code=php]
<?
include(“connection.php”);
?>
<html>
<head>
<script language=”javascript”>
function Validate( )
{
var Lform = this.document.form2;
if(Lform.combocategory.selectedIndex == “0” )
{
alert ( “Please Select Category.” );
return false;
}
return true;
}
</script>
</head>
<body>
<?php
$combocategory = $_POST[‘combocategory’];
echo $combocategory;
$q = “select * from category”;
$resultq = mysql_query($q);
$numq = mysql_num_rows($resultq);
echo “<center><b><h3>Add Product</center><br></b></h3>”;
echo “<form name=form1 action=addproductdata.php method=post onsubmit=”return Validate()”>”;
echo “<center><table>”;
echo “<tr>”;
echo “<td>”;
echo “Category”;
echo “</td>”;
echo “<form name=form2 action=addproduct.php method=post>”;
echo “<td>”;
echo “<select name=”combocategory” onchange=form2.submit()>”;
echo “<option value=”0″>Select</option>”;
while($row = mysql_fetch_array($resultq))
{
echo “<option value=””.$row[‘id’].””>”;
echo $row[‘product_cat’];
echo “</option>”;
}
echo “</select>”;
echo “</td>”;
echo “</form>”;
echo “</tr>”;
echo “<tr>”;
echo “<td>”;
echo “Sub-category”;
echo “</td>”;
echo “<td>”;
echo “<select name=”combosubcategory” onchange=”return Validate()”>”;
echo “<option value=”0″>Select</option>”;
if($combocategory != “”)
{
$q1 = “select * from category where cat_id=’$combocategory'”;
$resultq1 = mysql_query($q1);
$numq1 = mysql_num_rows($resultq1);
while($row1 = mysql_fetch_array($resultq1))
{
echo “<option value=””.$row1[‘id’].””>”;
echo $row1[‘product_cat’];
echo “</option>”;
}
}
echo “</select>”;
echo “</td>”;
echo “</tr>”;
echo “<tr>”;
echo “<td colspan=2 align=center>”;
echo “<input type=submit value=submit>”;
echo “</td>”;
echo “</tr>”;
echo “</table></center>”;
echo “</form>”;
?>
</body>