maaf jika pertanyaan saya membuat bingung para master..
begini certitanya...
andaikan saya ingin menampilkan data sbb brkt :
==baju=========harga====
merah --> 19.000
hijau --> 20.000
combobox3 --> textbox3

berdasarkan table baju
========================
==id===nm_baju===harga==
========================
01===== biru ===19.000=
02===== ungu ===30.000=

bagaimana carnya agar yang kita pilih di combox 1 untuk textbox 1, combo2 untuk textbox2 dst.. saya pernah baca jawaban bank Ellyx Christian tentang cobo dinamis, tetapi saya coba setiap saya memilih combo1,2 dan 3 yang textbox2 dan 3 tidak terisi dan kosong hanya merubah di textbox1 saja...mohon penceranhanya?
Silahkan login untuk menjawab!
0
Loading...
Ellyx Christian · Mar 30, 2013 · 0 Suka · 0 Tidak Suka
bisa lihat kode yang sudah dibuat?
0
Loading...
Elena · Mar 31, 2013 · 0 Suka · 0 Tidak Suka
Mohon Tolong saya bank Ellyx Christian, saya utak-utik udah 3 hari gak ketemu juga maklum baru belajar php..hehhehe..
masalahnya setiap pilih baju dari salah satu combox maka textbox y ikut berubah semua..bagaimana caranya bank Ellyx Christian agar setiap memilih combo1 mak muncul hrganya di textbox1, memilih combo2 mak muncul hrganya di textbox2, dan memilih combo3 mak muncul hrganya di textbox3...mohon petunjuk dan pencerahannya bank Ellyx Christian..Please
<?
	mysql_connect('localhost','root','231088') or die("Koneksi gagal");
	mysql_select_db('penjualan') or die("Database tidak bisa dibuka");
	
	$jsArray = "var idxhrg = new Array();";
	echo "<table width='60%' border='1'>
			<tr><td>Nama Baju</td><td>Harga Baju</td></tr>
			<tr>
				<td><select name='baju' name='baju' onchange='changeValue(this.value)'>
					<option value='pilih'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					$jsArray .= "idxhrg['" . $r[id] . "'] = {index:'" . addslashes($r['hrg'])."'};";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg' id='hrg'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju' name='baju' onchange='changeValue(this.value)'>
					<option value='pilih'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					$jsArray .= "idxhrg['" . $r[id] . "'] = {index:'" . addslashes($r['hrg'])."'};";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg' id='hrg1'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju' name='baju' onchange='changeValue(this.value)'>
					<option value='pilih'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					$jsArray .= "idxhrg['" . $r[id] . "'] = {index:'" . addslashes($r['hrg'])."'};";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg' id='hrg2'></td>
			</tr>
			</table>";
	?>
	<script type="text/javascript">    
    <?php echo $jsArray; ?>  
    function changeValue(id){  
    document.getElementById('hrg').value = idxhrg[id].index;
	document.getElementById('hrg1').value = idxhrg[id].index;
	document.getElementById('hrg2').value = idxhrg[id].index;
    };  
    </script>
0
Loading...
Elena · Mar 31, 2013 · 0 Suka · 0 Tidak Suka
Ini Untuk Sql Tablenya Bank Ellyx Christian
-- phpMyAdmin SQL Dump
-- version 2.10.2
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Mar 31, 2013 at 06:09 PM
-- Server version: 5.0.45
-- PHP Version: 5.2.3

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- 
-- Database: `penjualan`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `baju`
-- 

CREATE TABLE `baju` (
  `id` int(11) NOT NULL auto_increment,
  `nm_baju` varchar(30) NOT NULL,
  `hrg` int(11) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

-- 
-- Dumping data for table `baju`
-- 

INSERT INTO `baju` VALUES (1, 'Baju MU', 19000);
INSERT INTO `baju` VALUES (2, 'Baju Juventus', 30000);
INSERT INTO `baju` VALUES (3, 'Baju Real Madrid', 35000);
0
Loading...
Elena · Apr 2, 2013 · 0 Suka · 0 Tidak Suka
Akhirnya dah bisa juga Bank Ellyx Christian, tapi bagaimananya cara meresetnya kalo user memilih "PILIH BAJU" value di textbox tidak "undefined"... bagaimana cara mendapatkan valuenya sama dengan "0"... bagaimana logika if then y??please
<?
	include "koneksi.php";
	
	$jsArray1 = "var idxhrg1 = new Array();\n";
	$jsArray2 = "var idxhrg2 = new Array();\n";
	$jsArray3 = "var idxhrg3 = new Array();\n";
	echo "<table width='60%' border='1'>
			<tr><td>Nama Baju</td><td>Harga Baju</td></tr>
			<tr>
				<td><select name='baju' id='baju1' onchange='document.getElementById(\"hrg1\").value = idxhrg1[this.value]'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray1 .= "idxhrg1['" . $r[id] . "'] = {hrg1:'" . addslashes($r['hrg'])."'};";
					$jsArray1 .= "idxhrg1['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";

            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg1' id='hrg1'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju2' id='baju2' onchange='document.getElementById(\"hrg2\").value = idxhrg2[this.value]'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray2 .= "idxhrg2['" . $r[id] . "'] = {hrg2:'" . addslashes($r['hrg'])."'};";
					$jsArray2 .= "idxhrg2['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg2' id='hrg2'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju3' id='baju3' onchange='document.getElementById(\"hrg3\").value = idxhrg3[this.value]'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray3 .= "idxhrg3['" . $r[id] . "'] = {hrg3:'" . addslashes($r['hrg'])."'};";
					$jsArray3 .= "idxhrg3['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg3' id='hrg3'></td>
			</tr>
			</table>";
	?>
	<script type="text/javascript"> 
	<?php echo "$jsArray1 $jsArray2 $jsArray3";?>
    
    </script>
0
Loading...
Ellyx Christian · Apr 4, 2013 · 0 Suka · 0 Tidak Suka
<?
	include "koneksi.php";
 
	$jsArray1 = "var idxhrg1 = new Array();\n";
	$jsArray2 = "var idxhrg2 = new Array();\n";
	$jsArray3 = "var idxhrg3 = new Array();\n";
	echo "<table width='60%' border='1'>
			<tr><td>Nama Baju</td><td>Harga Baju</td></tr>
			<tr>
				<td><select name='baju' id='baju1' onchange='document.getElementById(\"hrg1\").value = idxhrg1[this.value] ? idxhrg1[this.value] : 0'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray1 .= "idxhrg1['" . $r[id] . "'] = {hrg1:'" . addslashes($r['hrg'])."'};";
					$jsArray1 .= "idxhrg1['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
 
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg1' id='hrg1'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju2' id='baju2' onchange='document.getElementById(\"hrg2\").value = idxhrg2[this.value] ? idxhrg2[this.value] : 0'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray2 .= "idxhrg2['" . $r[id] . "'] = {hrg2:'" . addslashes($r['hrg'])."'};";
					$jsArray2 .= "idxhrg2['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg2' id='hrg2'></td>
			</tr>";
	echo "	<tr>
				<td><select name='baju3' id='baju3' onchange='document.getElementById(\"hrg3\").value = idxhrg3[this.value] ? idxhrg3[this.value] : 0'>
					<option value='0'>Pilih Baju</option>";
					$tampil=mysql_query("SELECT * FROM baju ORDER BY nm_baju");
					while($r=mysql_fetch_array($tampil)){
					echo "<option value=$r[id]>$r[nm_baju]</option>";
					//$jsArray3 .= "idxhrg3['" . $r[id] . "'] = {hrg3:'" . addslashes($r['hrg'])."'};";
					$jsArray3 .= "idxhrg3['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
            }
    echo "  		</select>
				</td>
				<td><input type=text name='hrg3' id='hrg3'></td>
			</tr>
			</table>";
	?>
	<script type="text/javascript"> 
	<?php echo "$jsArray1 $jsArray2 $jsArray3";?>
 
    </script>
0
Loading...
Elena · Apr 7, 2013 · 0 Suka · 0 Tidak Suka
Terima kasih banyak bank...Mantap banget N sukses selalu....
0
Loading...
Elena · Apr 7, 2013 · 0 Suka · 0 Tidak Suka
Bank Minta tolong klo saya modif Skripnya seperti ini ko gak nonggol y harganya tolong bang...please
<?
include "koneksi.php";

echo "<script type='text/javascript'>";
echo "function startCalculate(){";
echo "interval=setInterval('Calculate()',10)";
echo "}";

echo "function Calculate(){\n";
echo "var total=0;\n";
for ($i=1; $i<=20; $i++){
echo "document.getElementsByName('Sub_totalharga[$i]')[0].value=(document.getElementsByName('harga[$i]')[0].value*document.getElementsByName('jumlah[$i]')[0].value).toFixed(0);\n";
echo "total+=parseFloat(document.getElementsByName('Sub_totalharga[$i]')[0].value);\n";
}
echo "document.getElementsByName('totalongkos_ptgbhn')[0].value=total.toFixed(0)\n";
echo "}";

echo "function stopCalc(){";
echo "clearInterval(interval)";
echo "}";
echo "</script>";
$jsArray1 = "var idxhrg1 = new Array();\n";
echo "<form name='form3' id='form3' method='post' action='lima.php'>
							<table border='1' width='90%'  cellspacing='0' cellpadding='3'>
							<tr><td align='center' width='20%'>Nama Baju</td>
								<td align='center' width='20%'>Harga Baju</td>
								<td align='center' width='20%'>Jumlah Beli (/ Pcs)</td>
								<td align='center' width='10%'>Sub Total Harga</td>
								<td align='center' width='10%'>Action</td>
							</tr>";
echo "	<tr id='last'>
		<td colspan='5' align='right'><button type='button' id='addRow'>Add Rows</button></td>
		</tr>
		<tr>
			<td colspan='3' align='center'>Grand Total harga</td>
			<td align='center'><input type='text' class='input-small' name='totalongkos_ptgbhn' id='totalongkos_ptgbhn' style='text-align:right'></td>
		</tr> 
		</table>
		<br>
		<input type='hidden' name='jum' value='$n'>
		<input type='submit' name='submit' value='Submit'>
	</form>";
?>
<script type="text/javascript" src=" jquery-1.7.2.min.js"></script>
<script type="text/javascript">
var i = 1;
$(function(){
$("#addRow").click(function(){
row = '<tr>'+
//Baju
'<td><select name="baju['+i+']" onchange="document.getElementById("harga['+i+']").value = idxhrg1[this.value] ? idxhrg2[this.value] : 0"> <option value="0">Pilih Item</option><?
			$tampil=mysql_query("SELECT * FROM baju");
			while($r=mysql_fetch_array($tampil)){
				  echo "<option value=$r[id]>$r[nm_baju]</option>";
				  	$jsArray1 .= "idxhrg1['" . $r[id] . "'] = '" . addslashes($r['hrg']) . "';\n";
			}?></select></td>'+
//Harga
'<td align="center"><input type="text" name="harga['+i+']" id="harga['+i+']" style="text-align:right" onFocus="startCalculate()" onBlur="stopCalc()"/></td>'+
//jumlah 
'<td align="center"><select name="jumlah['+i+']" style="width:100px; text-align:center" onFocus="startCalculate()" onBlur="stopCalc()"><?
	for ($a=0; $a<=50; $a++) {
	echo "<option value=$a>$a</option>";
	}
?></select></td>'+
//sub Total Harga
'<td align="center"><input type="text" name="Sub_totalharga['+i+']" style="text-align:right" onFocus="startCalculate()" onBlur="stopCalc()"/></td>'+
'<td align="center"><button type="button" class="del">Del</button></td>'+
'</tr>';
$(row).insertBefore("#last");
i++;
});
});
$(".del").live('click', function(){
$(this).parent().parent().remove();
});
<?php echo "$jsArray1";?>
</script>
0
Loading...
wisnu satrio husodo · Apr 7, 2014 · 0 Suka · 0 Tidak Suka
Maaf bang christian minta bantuanya
misal ada kasus sama seperti ini tapi dia memanggil data lebih dari satu data misal saya ambil contoh diatas dan tak tambahi.

berdasarkan table baju
========================
==id===nm_baju===harga==warna
=================================
01===== MU ===19.000====Merah
02===== Chealsea ===30.000====Biru

jadi combo box nya memanggil data akan muncul harga dan nama.