Jump to content

Archived

This topic is now archived and is closed to further replies.

shan_cool

Getting relevant values in combo boxes

Recommended Posts

Hi all,

I hav three combo boxes, 1)project name, 2)product name, 3)module name

If i choose any value in combo 1 its relevant products must be displayed in combo2 and if i choose any value in combo 2 its relevant modules must be displayed in combo3......

i hav done it wit combo2 and combo3..... ie) if i choose any value in cmbo2 its relevant records displyed in cmbo3.... how to do it for the 1st combo. the pbm is that page gets refreshed.. see my code and gimme suggestions:


<?php session_start();
require_once "include/connect.php";
$userid=$_SESSION['name'];
if ( $userid=="")
{
header("Location:index.php");
}
$_SESSION['min'] = 0;
?>
<html>
<head>
<script language="javascript">
<!--
function window_onload()
{
var qs=location.search.substring(1,location.search.length);
var pair = qs.split('=');
temp = unescape(pair[1]).split('+');
document.form1.prd_name.value=temp;
}
function Product_onblur()
{
var my_prd= "";
var index1=document.form1.prd_name.selectedIndex
my_prd=document.form1.prd_name.options[index1].value
window.location.href = unescape("log_defect.php"+"?prod_name="+my_prd);
}


function handldefect() {

if (document.form1.prd_name.value == "") {
alert ("Please Select Product Name !");
document.form1.prd_name.focus();
return false;
}
if (document.form1.mod_name.value == "") {
alert ("Please Select Module Name !");
document.form1.mod_name.focus();
return false;
}



}


//-->
</script>
<title>Defect Tracker- Maveric Systems Ltd.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
margin-top: 0px;
}
-->
</style></head>
<body LANGUAGE=javascript onload="return window_onload()">
<form action="log_update.php" method="post" id="form1" name="form1" onsubmit="return handldefect();">
<table width="955" height="575" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th scope="col"><table width="955" height="575" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F6F7FB">
<tr>
<th height="70" scope="col">
<div align="center">
<?php
require_once "./include/top.php";
?>
<?php
require_once "./include/topmenuclienttester1.php";

?>


</div></th>
</tr>
<tr>

<td height="310">
<div align="center">
<table width="955" cellpadding="0" cellspacing="0">
<TR>
<TD align="center" >
<td align="left" valign="top">
<TABLE width="955" cellspacing="0" cellpadding="0" bgcolor="#F6F7FB" >
<tr>
<td width="100" ><FONT face="Verdana" color=black size="2"><b>Project Name</b></font> </td>
<td width="200" align="left" height="50">
<select style="border-style:none; FONT-SIZE: 10pt; WIDTH: 137px; COLOR: #222222; " name="Product" style="font-size: 10pt" tabindex="1">
<?php
$query=mysql_query("SELECT name name FROM dt_admin where category ='pjname' order by name ASC",$connection )or die ("cant do it");
while ($result=mysql_fetch_array($query))
{
echo '<option value="' . $result['name'] . '">' . $result['name'] . '</option>';
}
?>
</select>&nbsp;<font color="red">*</font></td>


<td width="119" class="bodytext"><FONT face="Verdana" color=black size="2"><b>Product Name</b></font></td>
<td width="250" class="bodytext">
<select style="border-style:none; FONT-SIZE: 10pt; WIDTH: 137px; COLOR: #222222; " name="prd_name" style="font-size: 10pt" tabindex="2" onChange="return Product_onblur()">
<?php
$query=mysql_query("SELECT prod_name name FROM dt_product order by prod_name ASC",$connection )or die ("cant do it");
while ($result=mysql_fetch_array($query))
{
echo '<option value="' . $result['name'] . '">' . $result['name'] . '</option>';
}
?>

</select>&nbsp;<font color="red">*</font></td>
</tr>

<tr>
<td width="100" ><FONT face="Verdana" color=black size="2"><b>Module Name</b></font> </td>
<td width="200" align="left"height="50">
<select style="border-style:none; FONT-SIZE: 10pt; WIDTH: 137px; COLOR: #222222; " name="mod_name" style="font-size: 10pt" tabindex="3">
<OPTION value="" selected>SELECT</OPTION>
<?php
$prodname=$_GET[prod_name];
$query=mysql_query("SELECT module_name name FROM dt_module where prod_name='$prodname'order by module_name ASC",$connection )or die ("cant do it");
while ($result=mysql_fetch_array($query))
{
echo '<option value="' . $result['name'] . '">' . $result['name'] . '</option>';
}
?>
</select>&nbsp;<font color="red">*</font></td>


</tr>




<table align="center" width="955" bgcolor="#F6F7FB">
<tr>
<td align="right">
<input type=submit value=SUBMIT name=submit class="buttons" tabindex="14"></td>
<td align="left">
<input type=reset value=RESET name=reset class="buttons" tabindex="15"></td>
</tr>
</table>
</table>
</form>


</td>
</table>
</td>
</TD>
</TR>
</TABLE>



</table>
</div></td>
</tr>
<tr>
<td height="15"><div align="center">
<?php
require_once "./include/bottom.php";
?>
</div></td>
</tr>
</table></th>
</tr>
</table>
</body>
</html>

Rgds,
shan

Share this post


Link to post
Share on other sites
Only way to do it without refreshing using PHP would be to have litle iFrams and then each box is in a diffrent page and the submit uses the ifram target window to post too and then the last one actualy targets the main page instead of frame.. i havn't done this myself tho so not 100% on it. Only way without refreshing the page will be javascript or some other clientside language as PHP is parsed serverside.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.