Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 9th, 2005, 04:14 AM
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default Javascript question on reset and onfocus

1. How to reset textbox + textarea?
2. How to make the "function getKeyValue_h(chr)" work without the submit button? (on pasting in textarea it should automatically give the calculated result in the textbox.)

//&&& 1st of 2 instances of getKeyValue(). changed name of Fx, '_h' for hebrew? 
function getKeyValue_h(chr) { 
  if(chr=="A") return 1; 
  if(chr=="B") return 2; 
  if(chr=="G") return 3; 
  if(chr=="D") return 4; 
  if(chr=="H") return 5; 
  if(chr=="V") return 6; 
  if(chr=="X") return 8; 
  if(chr=="+") return 9; 
  if(chr=="Y") return 10; 
  if(chr=="k" || chr=="K") return 20; 
  if(chr=="L") return 30; 
  if(chr=="m" || chr=="M") return 40; 
  if(chr=="n" || chr=="N") return 50; 
  if(chr=="$") return 60; 
  if(chr=="O") return 70; 
  if(chr=="p" || chr=="P") return 80; 
  if(chr=="c" || chr=="C") return 90; 
  if(chr=="q") return 100; 
  if(chr=="R") return 200; 
  if(chr=="S") return 300; 
  if(chr=="T") return 400; 
  return 0; 

function computeValue(str) { 
  var ans=0; 
  for(var i=0; i<str.length; i++) { 
  return ans; 
Within <body> (does it have to be in a form too?):
<textarea name="hInput" id="hInput" rows="9" cols="64"
 class="onLoad" onmouseover="this.className='onMouseOver'"
<input type="button" value="calculate value" onclick="javascript:computeValue(document.all.hInput.value, 'h');"> 

<input type="reset" value="Clear" name="B2">

<input type="text" name="hOutput" id="hOutput" readonly="true">
Learning of our true origins.

I feel sorry:


Foreknowledge of A Natural Disaster
Washington was aware that a deadly Tidal Wave was building up in the Indian Ocean
Reply With Quote
  #2 (permalink)  
Old March 10th, 2005, 10:50 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts

You can use onchange event of the textarea/textbox to call function getKeyValue_h(chr)

Om Prakash
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
change TextBox.BackColor property onFocus event drasko ASP.NET 1.0 and 1.1 Basics 8 January 26th, 2009 12:23 AM
IE not performing onFocus event for <select> kapstan Javascript 4 January 24th, 2006 02:10 PM
reset a drop-down menu in javascript crmpicco Javascript How-To 4 September 29th, 2005 08:24 AM
javascript onclick question robs Javascript 1 January 19th, 2005 05:20 AM
Can dropdownlist OnFocus call a server-side method commerceJeff ASP.NET 1.0 and 1.1 Basics 6 July 19th, 2004 11:50 AM

All times are GMT -4. The time now is 08:11 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.