Displaying drop-down values in textbox

I’ve been on this for so long and cant seem to get it working. I am trying to display the value of a dropdown in a text box and i’ve tried so many things but it just wont work:

	$query3 = "SELECT contaminant, gac_value FROM gac_ea WHERE land_use = 'Allotment' ORDER BY id";
	$result3 = mysql_query($query3) or die(mysql_error());   
	echo "<select name=\\"contaminant[]\\" id=\\"contaminant\\" value=''></option>";
	echo "<option>Select </option>";
	    echo "<option value=$row[contaminant]> $row[contaminant] </option>"; } 
		echo "</select></td>"; 
        echo "<td class=\\"row3\\">";
        echo "<input type=\\"text3\\" name=\\"gac_value[]\\" id=\\"gav_value\\" value=\\"$row[gac_value]\\" disabled=\\"disabled\\" /> </td>"; 
 // End contaminant loop 

Any help’ll be greatly appreciated.

Let me clean that up for you

$query3 = 'SELECT contaminant, gac_value FROM gac_ea WHERE land_use="Allotment" ORDER BY id';
$result3 = mysql_query($query3) or die(mysql_error());
echo '<select name="contaminant[]" id="contaminant" value=""></option>';
echo '<option>Select</option>';
while($row=mysql_fetch_array($result3)) {
	echo '<option value="', $row['contaminant'], '">', $row['contaminant'], '</option>';
	// End contaminant loop
echo '</select></td>';
echo '<td class="row3">';
echo '<input type="text3" name="gac_value[]" id="gav_value" value="', $row['gac_value'], '" disabled="disabled" />';
echo '</td>';

Does that help? :slight_smile:
If not, could you please explain in more detail what your problem is? I’m not sure I’m following what you want to achieve exactly …


What you want to do is actually a javascript question, so I’ve created a new thread from the post you posted here.
Thread is here: http://www.sitepoint.com/forums/showthread.php?t=703406

This thread is now closed.