How Do I make a select box change on below select boxes according to above one


I am in a problem with select box thing. In our display there are a number of select boxes from top to Bottom ..  When I Change one value in Top select Box the corresponding change must occur
in Below select boxes.   The Data Retrieved from corresponding tables.


 I have some Select Boxes.
 Top one is CARD SIZE Box , below one is COLOR BOX , CODING OPTION BOX, then CORNER OPTION BOX (I am not mention any other select boxes which don't need that Dynamic Change).

When Visit first time they show the Default value of Table. When I First Select SIZE BOX The
 corresponding change occur in color BOX , IT's Done through AJAX. But on the COLOR BOX
change i need to change the value of Coding Option Select box. How it can possible.

Please visit site http://sacdigital.com/business-cards-c-1.html  It's the application I really need.

 please Help quickly Thanks in advance.... I attach Some of my Code ... pls help

 
Main Page Displaying select Boxes
tprinting.php
-----------------------------------
 
 
<?php
session_start();
require_once("classes/DB.Class.php");
include_once "session.php";
__autoload("Cart");
 
/*function getName($id)
{
$obj=new DBCon();
//$obj->table_name = "tbl_print_type";
$obj->table_name = "tbl_printing";
$obj->sel_condition="id = '$id' ";
$obj->res_array = array('id','feature');
$res=$obj->SelectSQL();	
$values=$obj->Fetch($res); 
return $values[0]['feature'];
}*/
//index.php?module=instyle&mode=printing
$obj=new DBCon();
//$sql = "select * from tbl_printing where id in(1,2)";
$sql = "select * from tbl_cardsize";
$resultsql = mysql_query($sql) or die("Query Error");
?> 
 
 
<div class="stepshd">
 
<div class="arrow"></div>
 
<div class="stepstxt">FEATURED PRODUCTS</div>
 
</div>
 
<script src="js/selectproduct.js"></script>
<div id="productList">
<form name="frm" method="post" action="">
 
<!--<strong>Product</strong><br/> 
<select  name="product" onchange="getValues(this.value)"> -->
 
 
 
<!--<select name="product" onchange="change()"> -->
<!--<option  value="Select Product">Select Product</option> -->
<?php
//for($i=0;$i<count($this->name);$i++)
//{ 
 
?> 
 
<!--<option   value="<?php //echo $this->id[$i]; ?>"><?php //echo $this->name[$i]; ?></option> --> 
<!--<option   value="2">Printing</option> --> 
<?php
//}
?><!--</select> --> 
 
 
 
<strong>Size</strong>
<br/>
<select name="size" id="size" onchange="getValues(this.value)" >
<?php 
//for($i=0;$i<count($this->name);$i++)
//for($i=0;$i<count($this->feature);$i++)
while($row = mysql_fetch_array($resultsql))
{ ?>
<option value="<?php echo $row['price']."+".$row['id']; ?>" ><?php echo $row['name']; ?> </option>
<?php
}
?>
</select>
<br/>
 
 
 
 
 
<div id="first">
<?php
$sqlcolor = "select * from tbl_print_small where type='color'";
$resultcolor = mysql_query($sqlcolor) or die("Error in color selection");
 
 
?>
 
 
 
<strong>Color</strong>
<br/>
 
<select name="color" id="color" onchange="changeValue()" >
 
<?php
while($rowcolor = mysql_fetch_array($resultcolor)) {?> 
<option value="<?php echo $rowcolor['price']; ?>" > <?php echo $rowcolor['feature']; ?></option>
<?php } ?>
</select>
<br />
 
 
 
 
<strong>Card Stock</strong>
<br/>
<?php
$sqlstock = "select * from tbl_print_small where type='cardstock'";
$resultstock = mysql_query($sqlstock) or die("Error in card stock selection");
 
 
?>
 
 
 
<select name="cardstock" id="cardstock" onchange="changeValue()"> 
<?php
while($rowstock = mysql_fetch_array($resultstock)) {?> 
<option value="<?php echo $rowstock['price']; ?>" > <?php echo $rowstock['feature']; ?></option>
 
<?php } ?> 
</select>
<br />
 
 
 
 
<strong>Coating Options</strong>
<br/>
<?php
$sqlcoat = "select * from tbl_print_small where type='coatingoption'";
$resultcoat = mysql_query($sqlcoat) or die("Error in coating option selection");
 
 
?>
 
 
 
<select name="coatingoption" id="coatingoption" onchange="changeValue()"> 
<?php
while($rowcoat = mysql_fetch_array($resultcoat)) {?> 
<option value="<?php echo $rowcoat['price']; ?>" > <?php echo $rowcoat['feature']; ?></option>
 
 
<?php } ?>
</select>
<br />
 
 
 
<strong>Corner Option</strong>
<br/>
<?php
$sqlcorner = "select * from tbl_print_small where type='corneroption'";
$resultcorner = mysql_query($sqlcorner) or die("Error in corner option selection");
 
 
?>
 
 
 
<select name="corneroption" id="corneroption" onchange="changeValue()"> 
<?php
while($rowcorner = mysql_fetch_array($resultcorner)) {?> 
<option value="<?php echo $rowcorner['price']; ?>" > <?php echo $rowcorner['feature']; ?></option>
 
<?php } ?>
</select>
<br />
 
 
 
 
 
<strong>Quantity</strong>
<br/>
<?php
   $sqlquantity = "select * from tbl_printing_quantity";
   $resultquantity = mysql_query($sqlquantity) or die("Error in Quantity selection");
   ?>
 
 
<select name="quantity" id="quantity" onchange="changeValue()">
<?php
while($rowquantity = mysql_fetch_array($resultquantity)) {?> 
<option value="<?php echo $rowquantity['quantityPrice']; ?>" > <?php echo $rowquantity['quantity']; ?></option>
<?php } ?>
</select>
<br />
 
 
 
<strong>Proof</strong>
<br/>
<?php
$sqlproof = "select * from tbl_print_small where type='proof'";
$resultproof = mysql_query($sqlproof) or die("Error in proof selection");
 
 
?>
 
<select name="proof" id="proof" onchange="changeValue()"> 
<?php
while($rowproof = mysql_fetch_array($resultproof)) {?> 
<option value="<?php echo $rowproof['price']; ?>" > <?php echo $rowproof['feature']; ?></option>
<?php } ?>
 
</select>
<br />
 
 
 
<strong>Shipping</strong>
<br/>
<?php
$sqlship = "select * from tbl_print_small where type='shipping'";
$resultship = mysql_query($sqlship) or die("Error in shipping selection");
 
 
?>
 
<select name="shipping" id="shipping" onchange="changeValue()"> 
<?php
while($rowship = mysql_fetch_array($resultship)) {?> 
<option value="<?php echo $rowship['price']; ?>" > <?php echo $rowship['feature']; ?></option>
<?php } ?>
 
</select>
<br />
</div>
 
 
 
 
 
 
<!--<br/> -->
 
 
 
<div id="txtHint"></div> 
<div id="message"></div>
 
<input type="submit" name="update" value="Update" class="button2"/>
</form>  
</div>
<div class="stepshd">
<div class="arrow"></div>
<div class="stepstxt">EASY STEPS FOR ORDER</div>
</div>
<div >
 <img src="images/1.jpg" />
<div class="order">Order online 24hrs  a  day or by phone -<span class="style2"> 800-431-5060</span></div>
<div class="yellowbuttn"><a href="index.php?module=instyle&mode=reg" class="yellowlink">Get Started Now</a></div>
</div>
<script language="javascript" type="text/javascript">
 
 
function changeValue()
{
//var sizeval = document.getElementById('size').value;
//alert("size "+sizeval);
var colorval = document.getElementById('color').value;
//alert("color "+colorval);
var cardstockval = document.getElementById('cardstock').value;
//alert("card "+cardstockval);
 
var coatingoptionval = document.getElementById('coatingoption').value;
 
var corneroptionval = document.getElementById('corneroption').value;
var quantityval = document.getElementById('quantity').value;
var proofval = document.getElementById('proof').value;
var shippingval = document.getElementById('shipping').value;
//alert("size"+sizeval+"colorval"+colorval+"card "+cardstockval+"coating "+coatingoptionval+"corner "+corneroptionval+"quantity "+quantityval+" proof "+proofval+" shipping "+shippingval);
 
var total = (parseInt(colorval)+parseInt(cardstockval)+parseInt(coatingoptionval)+parseInt(corneroptionval)+parseInt(proofval)+parseInt(shippingval))*parseInt(colorval);
//alert("Total value is "+total);
 
document.getElementById('message').innerHTML = "Total Amount is "+total;
}
</script>
----------------------------------------------------------------
  Ajax ---Calling Javascript file (js/selectproduct.js)
var xmlHttp;
function getValues(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request");
 return;
 }
var url="phpfiles/getProducts.php";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  document.getElementById("first").innerHTML="";
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
 } 
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
 
---------------------------------------------------------------------
Ajax Calling Server Script (getProducts.php)
<?php
$q=$_GET["q"];
//echo "q is ".$q;
list($first, $second) = split(' ', $q);
$con = mysql_connect('localhost', 'designer_scott', 'anitha');
if (!$con)
 {
 	die('Could not connect: ' . mysql_error());
 }
mysql_select_db("designer_scott", $con);
 
//Change Color Here
//$sql="SELECT DISTINCT itemDesc FROM tbl_products WHERE item = '".$q."'";
 
 $sql = "SELECT * FROM tbl_color WHERE cardId = '".$second."'";
 
$result = mysql_query($sql);
?>
<!--<strong>Size</strong> -->
<strong>Color</strong>
<br/>
<select  name="color">
<?php
while($row = mysql_fetch_array($result))
 { 	 	 	 	 	 	 	
 ?>
<option value="<?php echo  $row['price']."+".$row['id']; ?>"><?php echo  $row['name'] ?></option>
<?php
}
?>
</select><br/>
 
<!--<div style="display: none" > -->
<strong>Coating Options</strong>
<br/>
<?php
$sql="SELECT description FROM tbl_products WHERE item = '".$q."' and feature = 'Coating Options'";
$result = mysql_query($sql);
 
 ?>
 
<select  name="coating">
<?php
while($row = mysql_fetch_array($result))
{
?>
 
<option value="<?php echo  $row['description']; ?>"><?php echo  $row['description']; ?></option>
<?php
}
?>
</select>
<!--</div> -->
<br/>
 
 
<strong>Quantity</strong>
<br/>
 <select name="qty">
<option value="100">100</option>
<option value="250">250</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2500">2500</option>
<option value="5000">5000</option>
<option value="10000">10,000</option>
<option value="15000">15,000</option>
<option value="20000">20,000</option>
<option value="25000">25,000</option>
</select>
 
<?php
$sql="SELECT description FROM tbl_products WHERE item = '".$q."' and feature = 'Color'";
$result = mysql_query($sql);
 
 ?>
 <br/> 	
<strong>Color</strong>
<br/>
<select  name="Color">
<?php
while($row = mysql_fetch_array($result))
{
?>
 
<option value="<?php echo  $row['description']; ?>"><?php echo  $row['description']; ?></option>
<?php
}
?>
</select>
<br/>
 
<?php
$sql="SELECT description FROM tbl_products WHERE item = '".$q."' and feature = 'Card Stock'";
$result = mysql_query($sql);
 
 ?>
<strong>Card Stock </strong>
<br/>
<select  name="cardStock">
 <?php
while($row = mysql_fetch_array($result))
{
?>
<option value="<?php echo  $row['description']; ?>"><?php echo  $row['description']; ?></option>
<?php
}
?>
</select>
<br/>
 <?php
$sql="SELECT description FROM tbl_products WHERE item = '".$q."' and feature = 'Corner Option'";
$result = mysql_query($sql);
 
 ?>
<strong>Corner Option</strong>
<br/>
 
<select  name="cornerOption">
 <?php
while($row = mysql_fetch_array($result))
{
?>
<option value="<?php echo  $row['description']; ?>"><?php echo  $row['description']; ?></option>
<?php
}
?>
</select>
<br/>
 
 
<?php
$sql="SELECT * FROM tbl_products WHERE item = '".$q."'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
 ?>
<strong>Proof</strong>
<br/>
<select  name="proof">
<option value="Select proof">Select Proof</option>
<option value="FREE PDF Proof">FREE PDF Proof</option>
</select>
<br/>
 
 
<strong>Shipping</strong>
<br/>
<select  name="shipping">
<option value="Select shipping">Select Shipping</option>
<option value="FREE UPS Ground">FREE UPS Ground</option>
<option value="Next Day Air">Next Day Air</option>
</select>
<br/>
 
<?php
mysql_close($con); 
?>

Open in new window

screenshot.JPG
logicslabAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PHPeZCommented:
Hi,
I've posted an answer to a similar case like yours about a week earlier.

Please see the link below, may be it might help you?
http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_24305067.html

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
AJAX

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.