PDA

View Full Version : Javascript Q?


planetsim
11-19-2002, 02:30 AM
Ok.. Im trying to make functions for a textarea.. where if you press buttons like form buttons code will be parsed like the forums do..

eg.. if you press the B button you get[ B ][ /B ] mind the spaces as they'd get processed otherwise.. Now how can i do something like that... i wanna be able to let people put a url in.. and then i get the code i use in php to change it.. Unfortunately PHP aint compable of doing the thing i need at this point in time..

All help is appreciated if you can read through the mumble

kdjoergensen
11-19-2002, 12:52 PM
You can capture keystrokes in a textarea like this:

<textarea onkeydown="detect(event)" name="myelm">

</textarea>


<script language="javascript1.2">
<!--
function detect(evt){
var keyPres = evt.keyCode;
if (keyPres == 66){
// write to the text area
}
}
//-->
</SCRIPT>

Now, I don't recall the excact keycodes, you you can try to run a script which display them in the status bar as you press on them:

function detect(evt){
var window.status = evt.keyCode;
}