Hi There,
At the moment I have the script below and a seperate page, but would like to include it into my main page. The problem I have is when you select a value from the dropdown, the page submits to the value set in the main pages for value. Please can some one tell what I need to change inorder to have the script not submit the value that the main forms action is set to. Is there a way that I can set a different value for the action of the script and then add an if statemnt to the main form?
<? require (“config.php”); ?>
<?
$connection = mysql_connect($dbhost, $dbusername, $dbpassword);
$db = mysql_select_db($dbname);
?>
<head>
<title>Coleshill Biz</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<link rel=stylesheet type=”text/css” href=”../css/cb.css”>
</head>
<body bgcolor=”#DAE4DA”>
<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>
<tr>
<td colspan=”2″ ><div align=”center” class=”hgb”>
Please select the Category and Sub Category you
would like your listing to appear in.
</div></td>
</tr>
<tr>
<td align=”center”> </td>
</tr>
<tr>
<td align=”center”><form name=”cat_select” action=”<? echo “$PHP_SELF”; ?>” method=”POST”>
<?
//db connections
$cat = $_POST[‘cat’]; <a href=”add_confirm.php”>add_confirm.php</a>
$sub_cat = $
if(!isSet($cat))
{
$result = mysql_query(“select * from category”);
echo “<select name=”cat” class=”formtextbox” onChange=”javascript:document.cat_select.submit();”>”;
echo ” <option selected>Select Category</option>”;
while ($row = mysql_fetch_array($result))
{
echo “<option value=”.$row[‘cat_id’];
echo “>”.$row[‘cat_name’].”</option>”;
}
echo “</select>”;
}
else
{
$result = mysql_query(“select * from category”);
echo “<select name=”cat” class=”formtextbox” onChange=”javascript:document.cat_select.submit();”>”;
while ($row = mysql_fetch_array($result))
{
echo “<option value=”.$row[‘cat_id’];
if($cat == $row[‘cat_id’])
echo ” SELECTED”;
echo “>”.$row[‘cat_name’].”</option>”;
}
echo “</select>”;
if(!isSet($sub_cat))
{
echo “<br><br><span class = “maroontext”>Please select sub category </span>”;
$result1 = mysql_query(“select * from sub_category where cat_id=$cat”);
echo “<br><br><select name=”sub_cat” class=”formtextbox” onChange=”javascript:document.cat_select.submit();”>”;
echo ” <option selected>Select Category</option>”;
while ($row = mysql_fetch_array($result1))
{
echo “<option value=”.$row[‘subcat_id’];
echo “>”.$row[‘subcat_name’].”</option>”;
}
echo “</select>”;
}
else
{
$result1 = mysql_query(“select * from sub_category where cat_id=$cat”);
echo “<br><br><select name=”sub_cat” class=”formtextbox” onChange=”javascript:document.cat_select.submit();”>”;
while ($row = mysql_fetch_array($result1))
{
echo “<option value=”.$row[‘subcat_id’];
if($sub_cat == $row[‘subcat_id’])
echo ” SELECTED”;
echo “>”.$row[‘subcat_name’].”</option>”;
}
echo “</select>”;
print “<br><br><form> <input type=”button” value=”Close Window” onClick=”window.close()”> </form></p> “;
echo ‘<script language=”JavaScript”>’;
echo “window.opener.document.forms[1].cat.value = ‘$cat’;n”;
echo “window.opener.document.forms[1].sub_cat.value = ‘$sub_cat’;n”;
echo ‘</script>’;
}
}
?>
</form></td>
</tr>
</table>
<p align=”center”> </p>
</body>
</html>
THanks
Dill