Pretty simple, just dont know how to find the solution XS.

I have a combo box, that once u select the required attribute (A, B, C).

It should display the apporiate text of A, B, C below it.

So any ideas?

Thanks, Regards X

I said it in the other thread, have an onchange event to submit the page when you select a value from the dropdown list. When the page is submitted, you can know which option was selected from the dropdown list. ($val = $_POST; ) Then query the table with this value as condition and retrieve the data.

Comments
awesome as usual ;)

Hi nav33n, my php GURU!

<?php	$con = mysql_connect("localhost","root");	mysql_select_db("test");	$query = "select col1 from table";	$result = mysql_query($query);	echo "<form method='post' action='test.php'>";	echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>";	while($row = mysql_fetch_array($result)) {		$value = $row['col1'];		echo "<option value='".$value."'>$value</option>";	}	echo "</select>"; 	$firstdropdownlistvalue = $_POST['dropdown1'];	$query2 = "select * from table where col2 = '$firstdropdownlistvalue'";	$result2 = mysql_query($query2);	echo "<select name=dropdown2>";	while($row2 = mysql_fetch_array($result2)) {		$value2 = $row2['col1'];		echo "<option value='".$value2."'>$value2</option>";	}	echo "</select>";	echo "</form>";?><?php
	$con = mysql_connect("localhost","root");
	mysql_select_db("test");
	$query = "select col1 from table";
	$result = mysql_query($query);
	echo "<form method='post' action='test.php'>";
	echo "<select name=dropdown1 onchange='javascript<b></b>: document.form.submit();'>";
	while($row = mysql_fetch_array($result)) {
		$value = $row['col1'];
		echo "<option value='".$value."'>$value</option>";
	}
	echo "</select>";
	
	$firstdropdownlistvalue = $_POST['dropdown1'];
	$query2 = "select * from table where col2 = '$firstdropdownlistvalue'";
	$result2 = mysql_query($query2);
	echo "<select name=dropdown2>";
	while($row2 = mysql_fetch_array($result2)) {
		$value2 = $row2['col1'];
		echo "<option value='".$value2."'>$value2</option>";
	}
	echo "</select>";
	echo "</form>";
?>

From your other thread a few questions, as mine is linked to a mysql database which the values are retrieved from that.

I have pretty much everything you have there already minus the on change even like you said.

echo "<select name=dropdown1 onchange='javascript: document.form.submit();'>";

So this is the only code I need to add to let my form submit itself and show the appropriate data?

Also another quick Q, once I have selected the drop down item and refreshed the page, I wish to keep the selected item in the combo box and not be reset to the intial value.Any ideas?

Thanks for all your help again, ill try that now. - I just tested it and it works BUT my first drop down isnt refreshing but my second is =S (Ill go debug and keep you posted)

Regards, X

After a whole bunch of debugging everything is done!
Thanks nav once again your a legend ;)

This article has been dead for over six months. Start a new discussion instead.