koreksi combobox....

icha · Aug 14, 2012
link yang mas kasih kemaren.... descripnya ga mw nampil mas....mhon koreksinya
 
	<?php    
    $result = mysql_query("select * from product");    
    $jsArray = "var prdName = new Array();\n";    
    echo '<select name="prdId" onchange="changeValue(this.value)">';    
    echo '<option>-------</option>';    
    while ($row = mysql_fetch_array($result)) {    
        echo '<option value="' . $row['product_id'] . '">' . $row['product_id'] . '</option>';    
        $jsArray .= "prdName['" . $row['product_id'] . "'] = {name:'" . addslashes($row['product_name']) . "',desc:'".addslashes($row['product_desc'])."'};\n";    
    }    
    echo '</select>';    
    ?>    
    
    </select>
    <input type="text" name="prod_name" id="prd_name"/>
    <input type="text" name="prod_desc" id="prd_desc"/>
    <script type="text/javascript">    
    <?php echo $jsArray; ?>  
    function changeValue(id){  
    document.getElementById('prd_name').value = prdName[id].name;  
    document.getElementById('prd_desc').value = prdName[id].desc;  
    };  
    </script>  
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Aug 14, 2012 · 0 Suka · 0 Tidak Suka
struktur table-mu seperti apa?
0
Loading...
icha · Aug 15, 2012 · 0 Suka · 0 Tidak Suka
skrg sdh bisa mas,, krg teliti:D