SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    georgia
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    KeyCode Question

    In mozilla 1.0,

    i am using keycode event to show/hide div tag and also put focus on textbox in div tag. i am using s[keycode = 83]. when it brings focus to the textbox it also adds s. how can i remove the s. here is the code i have that does not work


    <script language="JavaScript">
    document.onkeydown = checkKeycode
    function checkKeycode(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;

    //alert("keycode: " + keycode);

    if(keycode == 13)
    {
    document.Form1.btnLastName.click();
    }
    if(keycode == 83)
    {
    //alert("keycode: " + keycode);
    if(document.getElementById('lyrSearchForm').style.visibility == 'visible')
    document.getElementById('lyrSearchForm').style.visibility = 'hidden';
    else
    document.getElementById('lyrSearchForm').style.visibility = 'visible';

    document.getElementById('txtExhibitId').focus();
    Form1.txtExhibitId.value = '';
    return false;

    }
    }
    </script>

    thanks for your help

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,499
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    </
    head>

    <
    body>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    vic=0;
    document.write('<style> .debug {VISIBILITY: visible; POSITION: absolute; TOP: 500px; z-Index:100; }</style>')
    <!---->
    </script>
    <div class=debug>
     <form name="Show">
     <input type="text" size="10" name="Show1" value="Show1">
     <input type="text" size="10" name="Show2" value="Show2">
     <input type="text" size="10" name="Show3" value="Show3">
     <input type="text" size="10" name="Show4" value="Show4">
     <input type="text" size="10" name="Show5" value="Show5">
     <input type="text" size="10" name="Show6" value="Show6">
     </form>
    </div>

     <script language="JavaScript">
    document.onkeydown = checkKeycode
    function checkKeycode(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    document.Show.Show1.value=keycode;

    //alert("keycode: " + keycode);

    if(keycode == 13)
    {
    //document.Form1.btnLastName.click();
    }
    if(keycode == 83)
    {
    //alert("keycode: " + keycode);
    //if(document.getElementById('lyrSearchForm').style.visibility == 'visible')
    //document.getElementById('lyrSearchForm').style.visibility = 'hidden';
    //else
    //document.getElementById('lyrSearchForm').style.visibility = 'visible';

    document.getElementById('txtExhibitId').focus();
    setTimeout("document.getElementById('txtExhibitId').value = '';",200);
    return false;

    }
    }
    </script>
    <input id="txtExhibitId" value="12345">

    </script>



    </body>

    </html> 


Bookmarks

Posting Permissions

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