Jump to content

Select Options Disappear On Change


son
 Share

Recommended Posts

I have a drop down that displays the available options for a product. Each time the select option is changed all options other than currently displayed item disappear from drop down. Why is that? The code is:

 if ($style != 2){ // size options$sq = "SELECT style_id, online_name, ns_id FROM mattresses WHERE ns_id='$nsproduct' OR parent='$nsproduct'";$sr = mysqli_query ($dbc, $sq) or die ('sorry');if ((mysqli_num_rows($sr) > 0)) {echo "<p class=\"dimHead\" style=\"clear: left; margin:15px 0 2px 0;\">Choose your size</p>";echo "<select onchange=\"window.location.href=this.value\">";echo "<option>Please select...</option>";	while (list($style_id, $name, $nsid, $size) = mysqli_fetch_array($sr, MYSQLI_NUM)) 	{	echo "<option value=\"mattresses_product.php?style=$style_id&id=$nsid\">$name</option>";	}echo "</select>";}}

Many thanks,Son

Link to comment
Share on other sites

Because you are only selecting the options for the current nsproduct in your SELECT query...

Link to comment
Share on other sites

Because you are only selecting the options for the current nsproduct in your SELECT query...
Also have at top of script:
if (isset($_GET['id'])) {	// if yes assign to $nsproduct	$nsproduct = (int) $_GET['id'];	// make sure the id is available	$query = "SELECT style_id, parent, ns_id FROM mattresses WHERE ns_id='$nsproduct'";	$result = mysqli_query ($dbc, $query) or die ('sorry');	if (mysqli_num_rows($result) == 0) 	{ 

This gets $nsproduct when new selection is made...Son

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...