You are not logged in.
Pages: 1
I'm not good at javascript, and most of my javascript codes I get are somewhere on the web. However, I wasn't able to find the desired code, so Please someone do care to write it for me
I just need the code to identify(while I'm writing into a textarea) a character(let's say %) and when it finds it, I want to execute a php code(which I already did)...
Thank you all very much and any help would really be appreciated
This will identify the key that you pressed and make an event out of it, i adjusted it to alert when you press %, you can change the charCode==37 (37 is %) to another charcode key.
Executing a server-side script like php is going to take a bit more than listening to an event. You're going to have to use AJAX.
If you're new to it, give JQuery a try.
Ra8 Could you please give me the code to the script you did?
And I guess you guys misunderstood what I was searching for.
It's like facebook's status updates, when You wanna tag someone, you just add @ and automatically it generates the available users in the database. thanks again!
Ra8 Could you please give me the code to the script you did?
It's JS... you can just right-click view source... anyway:
<textarea name="rene" cols="40" rows="3" onkeypress="on_up(event)"/></textarea>
<br/>CharCode of last key:<span></span>
<script>
function on_up (evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
document.getElementsByTagName("span")[0].innerHTML=charCode;
if(charCode==37){alert("You just pressed %");}
}
</script>
the @ is 64
Thank You Ra8
Pages: 1