Web Analytics Made Easy -
StatCounter Inserting Symbols - CodingForum

Announcement

Collapse
No announcement yet.

Inserting Symbols

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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
    The New JustaBuster Version 2.0 OR JustaBusta Lite V2.0
    ...just a special® thanx kinda hugs to jkd n' nex ...:O)))

    CommemorateWTC.com --Please lend your support

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment

        Working...
        X