View Full Version : Inserting Symbols

Ben Chivers
06-16-2002, 04:49 PM
I have made the following webpage so that users can insert symbols into the same webpage document. I have created it using radio buttons, but I can't seem to get it to work. I am having trouble with javascript recognizing the radio buttons.

You will see what I mean when you visit: http://www.easyscripts.co.uk/insertsymbol.htm

Could someone please help me to get it working correctly.

Any help would be most appreciated!

Many Regards,
Ben Chivers

06-16-2002, 06:09 PM
/me gets the radio button is just a undefined® :O((( n' thennn java just a starts® n' goes...do ya wanna close the window??? lol...

mayyybe this will just a help®...
tis from fpmc...:O))) just a copied/credited/saved...:O)))

Lancer, here's a standard format of a key press event in both IE4+ and NS4+

<Script language="JavaScript"><!--
NS = document.layers? 1:0;
if (NS) document.captureEvents(Event.KEYPRESS)
document.onkeypress = keyPress;

function keyPress(e) {
whKey = NS? e.which:event.keyCode;
if (whKey=="ASCII code") { myFunction(); }

Like jyoung said, the ASCII code here is a number which represents certain keys. But
instead of finding a suitable ASCII table, use the following script to test the key

<Script language="JavaScript"><!--
NS = document.layers? 1:0;
if (NS) document.captureEvents(Event.KEYPRESS)
document.onkeypress = testKey;

function testKey(e) {
whKey = NS? e.which:event.keyCode;

Put the above code on any page, open it, and press the keys. It will alert you the
proper ASCII code for that key you have pressed. Keep in mind that the letter 'p' and
'P' is represented by two different codes, and currently, javascript can only handle
alphanumeric keys (no arrow keys).

Ok, have fun

06-16-2002, 11:40 PM
Wow this new board is pretty cool - lots o' features

anyway Ben, you can't grab a radio value from an array in that manner, you need to loop through the array and find out which one is checked. Try replacing your function with the below:

function insertdata(){
var symbol = document.table.symbol;
if (symbol[i].checked) {
symbol = symbol[i].value;

Hope that helps
:thumbsup: <-- One click smilies I dig it :cool:

Ben Chivers
06-17-2002, 08:46 AM
Thanks for both of your replies, I really needed to stick with the radio buttons so I choose the second method.

I need the code because I am making a WYSIWYG html editor in a webpage with most of the function of frontpage.

Thanx again!
Ben Chivers