Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-16-2002, 03:49 PM   PM User | #1
Ben Chivers
New Coder

 
Join Date: Jun 2002
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Ben Chivers is an unknown quantity at this point
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 Chivers is offline   Reply With Quote
Old 06-16-2002, 05:09 PM   PM User | #2
justame
Regular Coder

 
Join Date: Jun 2002
Posts: 676
Thanks: 1
Thanked 0 Times in 0 Posts
justame is on a distinguished road
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)))

Code:
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
justame is offline   Reply With Quote
Old 06-16-2002, 10:40 PM   PM User | #3
boywonder
Regular Coder

 
Join Date: Jun 2002
Location: New York, USA
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
boywonder is an unknown quantity at this point
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
<-- One click smilies I dig it
boywonder is offline   Reply With Quote
Old 06-17-2002, 07:46 AM   PM User | #4
Ben Chivers
New Coder

 
Join Date: Jun 2002
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Ben Chivers is an unknown quantity at this point
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
Ben Chivers is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:05 AM.


Advertisement
Log in to turn off these ads.