Page 1 of 1

php combox click data will show into the text box

Posted: Sun Feb 23, 2014 2:28 pm
by manirul26
i have database like this
productid prdname size color price
101 carpet 40cm red 9000

suppose when i click on the combobox data will show in the 4 textbox , prdname,size,color,price.

i have write this code:

Code: Select all

<tr>
		<td width="20%">Product ID</td>
		<td>
		
		
		<select name="productid" onchange='UpdateTextbox(this)'>">
<?php
$query_disp="SELECT productid,prdname FROM carpet order by productid asc";
$result_disp = mysql_query($query_disp, $conn);
while($query_data = mysql_fetch_array($result_disp))
{
?>
<option value="<? echo $query_data['prdname']; ?>.<? echo $query_data['color']; ?>"<?php if ($query_data['productid']==$_POST['productid']) {?>selected<? } ?>><? echo $query_data['productid'];?></option>
<? } ?>
</select>
	</tr>
<tr>
		<td width="20%">Product Name</td>
		<td><input type="text" name="prdname" id="prdname"  value="<?php echo $prdname; ?>"></td>
	</tr>
	
	<tr>
		<td width="20%">Colour</td>
		<td><input type="text" name="color" id="color"  value="<?php echo $color; ?>"></td>
	</tr>
	<tr>
		<td width="20%">Size</td>
		<td><input type="text" name="Size" id="Size"  value="<?php echo $Size; ?>"></td>
	</tr>
	
	
	<tr>
		<td>Price</td>
		<td><input type="text" name="Price" id="Price"  value="<?php echo $Price; ?>"></td>
	</tr>
	
	

<script>
		 function UpdateTextbox(d){  
          document.getElementById('prdname').value = d.value;
		 
 }

</script>
when i click combo box 101 prdname is show in the prd textbox, other text box i cannot show i need help

i am new in php.

Re: php combox click data will show into the text box

Posted: Sun Feb 23, 2014 10:50 pm
by pbs
for that you need to use AJAX