Ari ni banyak menghabiskan masa untuk menulis kod php. module dah boleh run secara basic.. tapi kurang friendly skit.. nak adjust array yg di fetcth dr database supaya mengikut apa yg user masukkan..masalahnya apabila tekan kekunci ENTER utk turun ke baris baru tak berfungsi apabila di fetch dr database..outputnya jadi sebaris je.. setelah di searh dr merata-rata akhir nya jumpe 2 jenis 1 java script:
function whichButton() {
alert("got a key = " + event.keyCode);
if (event.keyCode == 13) {
var followingInput = document.getElementById("2");
followingInput.focus();
}
}
input id="1" type="text" name="fname" value="Mickey"
input id="2" type="text" name="lname" value="Mouse"
Important point is that you should handle the onkeyup event at the body level. In my case, I have 2 input text elements. When you are in the 1st text input element and type ENTER key(code = 13), then the focus will be set to the second element.
kira string test utk kod 113 bg enter value.
yg kedua nya PHP :
$text = htmlentities($text); echo '
'.ereg_replace("(\r\n¦\r¦\n)","
",$text).'
';I'm not a regular expression expert, but I think the above should match a newline regardless of the client machine.
What this is supposed to do is to replace all occurences of a newline with paragraph tags.
The first line also protects you from people entering HTML code in the text field.
0 Comments:
Post a Comment
<< Home