alexa-tracking

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/53056ffec1cb172e4e8b4695/ask-inner-html-menampilkan-dropdown-list-dari-database
[ASK] Inner HTML menampilkan Dropdown List dari Database
Mohon pencerahannya dari para Mastah-Mastah disini.

Code:
<td><?php
[color=green][B][size="4"]$result1 = mysql_query("SELECT cAccNum,sAccName FROM mstaccount WHERE LEFT(caccnum,1) IN ('5','6') AND clevel='4'");
$jsArracct = "var noid = new Array();\n";
echo '<select name="cbacct[]" id="idacct[]" style="font-family:Calibri; font-size:14px">';
echo '<option> < Account > </option>';
while ($row = mysql_fetch_array($result1)) {
echo '<option value="' . $row['cAccNum'] . '">'.$row['cAccNum'].'</option>';
$jsArracct .= "noid['" . $row['cAccNum'] . "'] = '" . addslashes($row['cAccNum']) . "';\n";
}
echo '</select>';[/size][/B][/color]
?>
</td>


Terus ane juga punya Script ini Mastah

Code:
[removed]
var norow = 2;
function tam(){
var x=document.getElementById('purchase').insertRow(norow);
var td1=x.insertCell(0);
var td2=x.insertCell(1);
var td3=x.insertCell(2);
var td4=x.insertCell(3);
var td5=x.insertCell(4);
var td6=x.insertCell(5);

td1[removed]="<input type='text' name='arrno[]' size='5' style='font-family:Calibri; font-size:14px'>";
td2[removed]="<input type='text' name='arrdesc[]' size='50' style='font-family:Calibri; font-size:14px'>";
[color=green][size="4"][B]td3[removed]="<select name='cbacct[]' id='idacct[]' style='font-family:Calibri; font-size:14px'> <option>< Account ></option> </select>";[/B][/size][/color]
td4[removed]="<input type='text' name='amtdtl[]' size='15' style='font-family:Calibri; font-size:14px'>";
td5[removed]="<input type='text' name='cbccid[]' size='8' style='font-family:Calibri; font-size:14px'>";
td6[removed]="<input type='text' name='cbtax[]' size='8' style='font-family:Calibri; font-size:14px'>";

norow++;
}


Dropdown list yang di Inner HTML juga seharusnya mengambil OPTION dari database. Mohon bantuannya Mastah.
phpnya diubah dikit:
Code:

$jsArracct = new array();
$result1 = mysql_query("SELECT cAccNum,sAccName FROM mstaccount WHERE LEFT(caccnum,1) IN ('5','6') AND clevel='4'");
while ($row = mysql_fetch_array($result1)) {
$jsArracct[$row[cAccNum]] = $row[sAccName ];
}

foreach($jsArracct as $obj => $value){
echo '<option value="' . $obj . '">'.$value.'</option>';
}


di JS nya:
Code:

td3[removed]="<select name='cbacct[]' id='idacct[]' style='font-family:Calibri; font-size:14px'> ";
<?php
foreach($jsArracct as $obj => $value){
echo 'td3[removed]+="<option value=' . $obj . '>'.$value.'</option>"';
?>
echo 'td3[removed]+="</select>"';
}
muncul Error gan pada bagian JS'nya
masalah di kurung kurawalnya.

Quote:Parse error: syntax error, unexpected $end in

bisa dibantu lagi gan emoticon-Malu (S)