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

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 07-19-2011, 12:00 AM   PM User | #1
Seb Meikle
New Coder

 
Join Date: Jul 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Seb Meikle can only hope to improve
Using JavaScript to Simulate Enter

Is it possible to use JavaScript to automatically press the Enter key when a textfield's value is changed? I'm guessing I would need to call the function using onChange="functionexample".

After some research I found out the the map number for the Enter key is 13. I think this is the number JavaScript needs, I could be wrong.
Seb Meikle is offline   Reply With Quote
Old 07-19-2011, 05:48 AM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
why do you want to press enter?
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 07-19-2011, 05:59 PM   PM User | #3
Seb Meikle
New Coder

 
Join Date: Jul 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Seb Meikle can only hope to improve
I have a form which has a section to choose a door number, each numeral is charged at £2.00. I have a script that calculates the amount of digits and that value is placed in a textfield.

I also have another textfeild that shows the total value of the order, but the problem is that the total value won't update when the amount of digits changes. If you click in the field with the amount of digits and press enter it updates the total value.

This was just a way round it I could think of.
Seb Meikle is offline   Reply With Quote
Old 07-19-2011, 07:52 PM   PM User | #4
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
i ask because pressing enter usually triggers a form submit or onchange event.
if that's the case, you can simply call form.submit() or input.onchange() - no reason to fake key presses...



in other words, just do what enter does, don't do enter.

post the code if you need a hand.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 07-20-2011, 06:00 PM   PM User | #5
Seb Meikle
New Coder

 
Join Date: Jul 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Seb Meikle can only hope to improve
Ah I see.

Just need to clarify where I should call this function?

Should it be on:
  • The textfield with the amount of digits?
  • The textfeild with the total value?
  • The form itself?

I was going to post the code, but it's too long. If you really need it to help me I will upload a text file.
Seb Meikle 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 09:25 PM.


Advertisement
Log in to turn off these ads.