/    Sign up×
Community /Pin to ProfileBookmark

Nesting Of fORM tags

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`s drown is changed.
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[/url]

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>[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 24.2006 — Form elements may not contain other form elements. Doing so renders your HTML markup invalid.
×

Success!

Help @Jaydeep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...