Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    New York, USA
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jun 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •