Jump to content


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


One last dropdown issue...

Recommended Posts

Hey maybe someone can help me with this i have tried all i know about it. I have 3 dropdowns all of which work correctly accept for one problem. When the user refreshes the first one and changes their choice it repopulates the second one like it should but the 3rd one isnt reset as well. How do i set the first one aka industry ot send a blank value to the url for both of the 2 corresponding menu's after it??? here is my code..

[code]<?php require_once('Connections/conn_dj.php'); ?>

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_industry = "SELECT industry_id, industry_name FROM tbl_industry ORDER BY industry_name ASC";
$rs_industry = mysql_query($query_rs_industry, $conn_dj) or die(mysql_error());
$row_rs_industry = mysql_fetch_assoc($rs_industry);
$totalRows_rs_industry = mysql_num_rows($rs_industry);

mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_outsidena = "SELECT * FROM intl_countries ORDER BY intl_countries.name";
$rs_outsidena = mysql_query($query_rs_outsidena, $conn_dj) or die(mysql_error());
$row_rs_outsidena = mysql_fetch_assoc($rs_outsidena);
$totalRows_rs_outsidena = mysql_num_rows($rs_outsidena);

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>DICKEY-john Corporation | Distributors</title>
<link href="_lib/sub.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="Distributor, Sales, Purchase, U.S., International" />
<meta name="description" content="Enter your zip or postal code to find the DICKEY-john distributor nearest you." />


<div id="black">&nbsp;</div>
<div id="siteContainer">
<?php include("_inc/topNav.inc"); ?>
<div id="headerContainer">Distributors</div>
<div class="divContainer"><div class="horizDiv"></div><img src="/_img/divEnd.png" alt="div" height="16" width="4" align="right" /></div>
<div id="contentContainer">
<div id="fullContainer">
<div id="stretchCrumbs">
<a href="/index.php">Home</a>
&#187; <a class="high" href="/distributors/">Distributors</a>
<p>Search for DICKEY-john distributers by specifying any combination of the<br />
following classifications: industry, product category, product, and state.</p>
<br />

<br />

<h2>North America</h2>
<form name="distributers">
  <table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="15%">Industry:</td>
    <td width="85%">
    <select name="industry_id" id="industry" onchange="document.distributers.value='industry';document.distributers.submit();" >
      <option value="">Select an Industry...</option>
      <?php do { ?>
  print "<option value=\"{$row_rs_industry['industry_id']}\"" .
    (isset($_GET['industry_id']) && $_GET['industry_id'] == $row_rs_industry['industry_id'] ? " selected>" : ">") .
      <?php } while ($row_rs_industry = mysql_fetch_assoc($rs_industry)); ?>
<tr><td>Product category:</td><td>

<?php if ($_GET['industry_id'] == null || $_GET['industry_id'] == "") { ?>
<select name="productCat_id" id="center" onchange="document.distributers.value='productCat_id';document.distributers.submit();" disabled>;
<?php } else {
mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_productcategory = "SELECT productCat_id, productCat_name, industry_id FROM tbl_productcat WHERE industry_id = '$_GET[industry_id]' ORDER BY productCat_name";
$rs_productcategory = mysql_query($query_rs_productcategory, $conn_dj) or die(mysql_error());
$row_rs_productcategory = mysql_fetch_assoc($rs_productcategory);
$totalRows_rs_productcategory = mysql_num_rows($rs_productcategory);
<select name="productCat_id" id="center" onchange="document.distributers.value='productCat_id';document.distributers.submit();" >
      <option value="">Select a product category...</option>
<?php do {
  print "<option value=\"{$row_rs_productcategory['productCat_id']}\"" .
    (isset($_GET['productCat_id']) && $_GET['productCat_id'] == $row_rs_productcategory['productCat_id'] ? " selected>" : ">") .
    } while ($row_rs_productcategory = mysql_fetch_assoc($rs_productcategory)); ?>
<?php } ?></td>


<?php if ($_GET['productCat_id'] == null || $_GET['productCat_id'] == "" || $_GET['industry_id'] == null || $_GET['industry_id'] == "") { ?>
<select name="product_id" id="center" onchange="document.distributers.value='products_id';document.distributers.submit();" disabled>;
<?php } else {
mysql_select_db($database_conn_dj, $conn_dj);
$query_rs_product = "SELECT products_id, products_name, productCat_id FROM tbl_products WHERE productCat_id = '$_GET[productCat_id]' ORDER BY products_name";
$rs_product = mysql_query($query_rs_product, $conn_dj) or die(mysql_error());
$row_rs_product = mysql_fetch_assoc($rs_product);
$totalRows_rs_product = mysql_num_rows($rs_product);
<select name="products_id" id="center" onchange="document.distributers.value='products_id';document.distributers.submit();" >
      <option value="">Select a product...</option>
<?php do {
  print "<option value=\"{$row_rs_product['products_id']}\"" .
    (isset($_GET['products_id']) && $_GET['products_id'] == $row_rs_product['products_id'] ? " selected>" : ">") .
    } while ($row_rs_product = mysql_fetch_assoc($rs_product)); ?>
<?php } ?>
    <tr><td>&nbsp;</td><td><input type="submit" value="Find" name="find"></td></tr>

<br />
<h2>Outside North America </h2>
<table class="setTbl listTbl" width="90%" cellpadding="0" cellspacing="0" border="0">
          <select name="outna" id="center" onchange="javascript:document.centerform.submit()">
        <option value="">Select a country...</option>
        <?php do { ?>
  print "<option value=\"{$row_rs_outsidena['id']}\"" .
    (isset($_GET['id']) && $_GET['id'] == $row_rs_outsidena['id'] ? " selected>" : ">") .
      <?php } while ($row_rs_outsidena = mysql_fetch_assoc($rs_outsidena)); ?> </select>

<?php include("_inc/footer.inc"); ?>





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.