form submit problem
i have two list menus and one of them shows itself depending on the option selected on the first one. Then, I have another field not dependent and two text fields. The problem I have it is that I wanna submit the form to a another page so the contents could be inserted into a database and show some results as well. However, the page the form it is configured so it reloads itself in order for the dependent menus to work properly. If i change the form action it also affects the dropdown box making submit the form to that page. how can i submit the form to a different page but still have the dropdowns reload the same page?
any help I will greatly appreciate.
Here it's the code:
<?php require_once('Connections/sin.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_subcat = "-1";
if (isset($_GET['category'])) {
$colname_subcat = $_GET['category'];
}
if(isset($_GET["category"]) && is_numeric($_GET["category"]))
{
$category = $_GET["category"];
}
if(isset($_GET["item"]) && is_numeric($_GET["item"]))
{
$items = $_GET["item"];
}
mysql_select_db($database_sin, $sin);
$query_subcat = sprintf("SELECT `desc`, `id` FROM cats WHERE id = %s", GetSQLValueString($colname_subcat, "int"));
$subcat = mysql_query($query_subcat, $sin) or die(mysql_error());
$row_subcat = mysql_fetch_assoc($subcat);
$totalRows_subcat = mysql_num_rows($subcat);
mysql_select_db($database_sin, $sin);
$query_Vendor = "SELECT * FROM vendors ORDER BY name ASC";
$Vendor = mysql_query($query_Vendor, $sin) or die(mysql_error());
$row_Vendor = mysql_fetch_assoc($Vendor);
$totalRows_Vendor = mysql_num_rows($Vendor);
?>
<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<p align="center" class="style4">IHD NEW ITEM REGISTRATION
<p align="center" class="style4">
<p align="center" class="style4">
<form name="theForm" method="get">
<p> </p>
<table width="685" height="458" align="center">
<tr>
<td width="278" class="style5 style8">Select Category:</td>
<td width="395" class="style5"><select name="category" class="style3" onchange="autoSubmit();">
<option value="9">Select Category</option>
<option value="1" <?php if($colname_subcat == 1) echo " selected"; ?>>Hydraulics</option>
<option value="2" <?php if($colname_subcat == 2) echo " selected"; ?>>Mechanical Items</option>
<option value="3" <?php if($colname_subcat == 3) echo " selected"; ?>>Electrical Items</option>
<option value="4" <?php if($colname_subcat == 4) echo " selected"; ?>>Service/Repair</option>
<option value="5" <?php if($colname_subcat == 5) echo " selected"; ?>>Miscellaneous</option>
<option value="6" <?php if($colname_subcat == 6) echo " selected"; ?>>Cane Handling</option>
<option value="7" <?php if($colname_subcat == 7) echo " selected"; ?>>Cane Milling</option>
<option value="8" <?php if($colname_subcat == 8) echo " selected"; ?>>Cane Equip. Misc.</option>
<option value="9" <?php if($colname_subcat == 0) echo " selected"; ?>>Other</option>
</select></td>
</tr>
<tr>
<td class="style9">Select Item Type:</td>
<td class="style5"><label>
<select name="item" id="item">
<option value="9">Select Item Type</option>
<?php
do {
?>
<option value="<?php echo $row_subcat['id']?>"><?php echo $row_subcat['desc']?></option>
<?php
} while ($row_subcat = mysql_fetch_assoc($subcat));
$rows = mysql_num_rows($subcat);
if($rows > 0) {
mysql_data_seek($subcat, 0);
$row_subcat = mysql_fetch_assoc($subcat);
}
?>
</select>
</label>
</select> </td>
</tr>
<tr>
<td class="style9">Select Vendor:</td>
<td class="style5"><label>
<select name="Vendor" id="Vendor">
<option value="null">Select Vendor</option><?php
do {
?>
<option value="<?php echo $row_Vendor['id']?>"><?php echo $row_Vendor['name']?></option><?php
} while ($row_Vendor = mysql_fetch_assoc($Vendor));
$rows = mysql_num_rows($Vendor);
if($rows > 0) {
mysql_data_seek($Vendor, 0);
$row_Vendor = mysql_fetch_assoc($Vendor);
}
?>
</select>
</label></td>
</tr>
<tr>
<td class="style9">Enter Parts Description:</td>
<td class="style5"><input name="Desc_p" type="text" id="Desc_p" size="50" /></td>
</tr>
<tr>
<td class="style9">Enter Sales Description:</td>
<td class="style5"><label>
<input name="desc_s" type="text" id="desc_s" size="50" />
</label></td>
</tr>
<tr>
<td colspan="2" class="style5"><div align="center">
<label>
<input type="submit" name="Submit" id="Submit" value="Save And Get Stock Number"/>
</label>
</div></td>
</tr>
</table>
<p><br>
</p>
</form>
|