Helpful Information
 
 
Category: Client side development
Inserting Symbols

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

ben...
/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(); }
}
//--></Script>

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
pressed:

<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;
alert(whKey)
}
//--></Script>

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
Frank

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;
for(i=0;1<symbol.length;i++){
if (symbol[i].checked) {
symbol = symbol[i].value;
break;
}
}
alert(symbol);
document.write(symbol);
window.close();
}

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

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










privacy (GDPR)