$query=mysql_query("select nomor from daftarpesan");
while($k=mysql_fetch_array($query)){
echo'<input type="text" name="jumlah'.$k[nomor].'" id="jumlah'.$k[nomor].'"/>';
echo '<a href="#" class="showkeyboard">Keyboard</a>';
}
kemudian ubah javascriptnya menjadi:$(document).ready(function(){
var shifton = false;
var txt = "";
// toggles the keyboard to show or hide when link is clicked
$(".showkeyboard").click(function(e) {
e.preventDefault();
var height = $('#keyboard').height();
var width = $('#keyboard').width();
leftVal=e.pageX-40+"px";
topVal=e.pageY+20+"px";
$('#keyboard').css({left:leftVal,top:topVal});
if(txt != $(this).prev().attr('id')){
txt = "#"+$(this).prev().attr('id');
$("#keyboard").show();
}else{
$("#keyboard").hide();
}
});
// makes the keyboard draggable
$("#keyboard").draggable();
// toggles between the normal and the "SHIFT keys" on the keyboard
function onShift(e) {
var i;
if(e==1) {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).hide();
$(rowid+"_shift").show();
}
}
else {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).show();
$(rowid+"_shift").hide();
}
}
}
// function thats called when any of the keys on the keyboard are pressed
$("#keyboard input").bind("click", function(e) {
if( $(this).val() == 'Backspace' ) {
$(txt).replaceSelection("", true);
}
else if( $(this).val() == "Shift" ) {
if(shifton == false) {
onShift(1);
shifton = true;
}
else {
onShift(0);
shifton = false;
}
}
else {
$(txt).replaceSelection($(this).val(), true);
if(shifton == true) {
onShift(0);
shifton = false;
}
}
});
});
echo'<input type="text" name="jumlah'.$k[nomor].'" id="jumlah'.$k[nomor].'"/>';
echo'<input type="text" name="jumlah'.$k['nomor'].'" id="jumlah'.$k['nomor'].'"/>';
var txt = "";
$(document).ready(function(){
var shifton = false;
// toggles the keyboard to show or hide when link is clicked
$(".showkeyboard").click(function(e) {
e.preventDefault();
var height = $('#keyboard').height();
var width = $('#keyboard').width();
leftVal=e.pageX-40+"px";
topVal=e.pageY+20+"px";
$('#keyboard').css({left:leftVal,top:topVal});
if(txt != '#'+$(this).prev().attr('id')){
txt = "#"+$(this).prev().attr('id');
$("#keyboard").show();
}else{
txt = '';
$("#keyboard").hide();
}
});
// makes the keyboard draggable
$("#keyboard").draggable();
// toggles between the normal and the "SHIFT keys" on the keyboard
function onShift(e) {
var i;
if(e==1) {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).hide();
$(rowid+"_shift").show();
}
}
else {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).show();
$(rowid+"_shift").hide();
}
}
}
// function thats called when any of the keys on the keyboard are pressed
$("#keyboard input").bind("click", function(e) {
if( $(this).val() == 'Backspace' ) {
$(txt).replaceSelection("", true);
}
else if( $(this).val() == "Shift" ) {
if(shifton == false) {
onShift(1);
shifton = true;
}
else {
onShift(0);
shifton = false;
}
}
else {
$(txt).replaceSelection($(this).val(), true);
if(shifton == true) {
onShift(0);
shifton = false;
}
}
});
});
var txt = "";
$(document).ready(function(){
var shifton = false;
// toggles the keyboard to show or hide when link is clicked
$(".showkeyboard").click(function(e) {
e.preventDefault();
var height = $('#keyboard').height();
var width = $('#keyboard').width();
leftVal=e.pageX-40+"px";
topVal=e.pageY+20+"px";
$('#keyboard').css({left:leftVal,top:topVal});
if(txt != '#'+$(this).prev().attr('id')){
txt = "#"+$(this).prev().attr('id');
$("#keyboard").show();
}else{
txt = '';
$("#keyboard").hide();
}
});
// makes the keyboard draggable
$("#keyboard").draggable();
// toggles between the normal and the "SHIFT keys" on the keyboard
function onShift(e) {
var i;
if(e==1) {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).hide();
$(rowid+"_shift").show();
}
}
else {
for(i=0;i<4;i++) {
var rowid = "#row" + i;
$(rowid).show();
$(rowid+"_shift").hide();
}
}
}
// function thats called when any of the keys on the keyboard are pressed
$("#keyboard input").bind("click", function(e) {
if( $(this).val() == 'Backspace' ) {
$(txt).replaceSelection("", true);
}
else if( $(this).val() == "Shift" ) {
if(shifton == false) {
onShift(1);
shifton = true;
}
else {
onShift(0);
shifton = false;
}
}
else {
var texts = $(this).val().split('');
for(i=0;i<texts.length;i++){
$(txt).replaceSelection(texts[i], true);
}
if(shifton == true) {
onShift(0);
shifton = false;
}
}
});
});