display content in a hidden div based on list using ID

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

display content in a hidden div based on list using ID

Post by jonnyfortis »

I am really stuck here.

I have a select list that is getting products off a mySQL db the products displayed in a select list. when one of the items is selected i want the content to show is a new div on the same page. I currently have the select list worlking but i dont know where to go from there.

here is what i have

Code: Select all

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $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;
}
}

mysql_select_db($database_beau, $beau);
$query_Recordset1 = "SELECT * FROM beaProdSizes, beauCat WHERE beaProdSizes.CatID = beauCat.catID";
$Recordset1 = mysql_query($query_Recordset1, $beau) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

<form id="FormName" action="" method="get" name="FormName">
			<select id="selectName" name="name">
                      <option value="Select Design">Select Design</option>
                      <?php
do { 
?>
                      <option value="<?php echo $row_Recordset1['name']; ?>"><?php echo $row_Recordset1['name']; ?></option>
                      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
            $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>



so when the record is selected i need the rest of the information to show up under the select list

thanks in advance
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: display content in a hidden div based on list using ID

Post by Celauran »

jQuery. Use a .change() listener to fetch the data asynchronously.
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: display content in a hidden div based on list using ID

Post by jonnyfortis »

thanks, will check it out
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: display content in a hidden div based on list using ID

Post by jonnyfortis »

Hi i have tried the script and it seems to interfere with the lightbox script i am using. also can it be used for dynamic content?

this is the other script i am using

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

and this is my dynamic content


<form id="FormName" action="blah.php" method="get" name="FormName">
<select id="selectName" name="name">
<option value="Select Design">Select Design</option>
<?php
do {
?>
<option selected="selected" value="<?php echo $row_Recordset1['name']; ?>"><?php echo $row_Recordset1['name']; ?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select>
</form>


thanks in advance
Post Reply