Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8121605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:32:51+00:00 2026-06-06T05:32:51+00:00

Trying to figure out how to type (via events not set the value) on

  • 0

Trying to figure out how to type (via events not set the value) on an input box for IE8 and 9. I looked at some of the examples on the web – but couldn’t get any of they to work. (I don’t want to rely on jQuery of other libraries).

Here is what I have so far:

<form>
  <input type="text" id="txtfld" /> 
  <input type="button" onclick="typeKey()" /> 
</form>
<script>

function typeKey(){
    var  txtField = document.getElementById('txtfld');
    var evt= document.createEventObject();
    evt.keyCode=68;
    txtField.fireEvent('onkeypress', evt);
}
</script>

It does not work, and it does not give an error either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:32:52+00:00Added an answer on June 6, 2026 at 5:32 am

    Try this function, fire(document.getElementById('txtfld'),'keypress',68):

    function fire(el,evttype,code) {
       if (document.createEvent) {
         var evt = document.createEvent('HTMLEvents');
         evt.initEvent( evttype, false, false);
         evt.charCode= evt.keyCode = code;
         el.dispatchEvent(evt);
       } else if (document.createEventObject) {
         var evt = document.createEventObject();
         evt.charCode= evt.keyCode = code;
         el.fireEvent('on' + evttype, evt);
       }
    }
    

    here an example

    good luck 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive been trying to figure out how to get some data i type into
I am trying to figure out what type of structure or container I should
Trying to figure out why File Attachment isn't showing on a custom content type.
trying to figure out why this is happening - I have an input text
Trying to figure out the best way to set up collection lists for users
I'm trying to figure out the type of the parameters passed to a function.
I am trying to figure out why my javascript that creates input elements on
I'm trying to figure out what data type to use... Basically I want a
Trying to figure out why this swf which is loaded via javascript which is
Trying to figure out how I can do this properly. The print_r looks like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.