p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   replacing "alert" with a textbox (http://p2p.wrox.com/showthread.php?t=26638)

gilgalbiblewheel March 9th, 2005 06:06 PM

replacing "alert" with a textbox
I wanted to merge 2 textboxes into 1. I put <%%> tags on the original additional textbox and its submit button. Instead I added a textbox id="t1" under the "reset".

I'm stuck on replacing the former "alert" in javascript with the "t1" textbox. There's no error showing but the textbox "t1" doesn't function.

Here's the link:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <meta name="description" content="" />
  <meta name="keywords" content="" />
  <meta http-equiv="Content-Type" content="text/html; UTF-8" />
  <meta name="author" content="" />
  <script type="text/javascript">
   //&&& 1st of 2 instances of getKeyValue(). changed name of Fx, '_h' for hebrew?
   function getKeyValue_h(chr) {
   //A switch statement is more efficient for this
     case "A": return 1;
     case "B": return 2;
     case "G": return 3;
     case "D": return 4;
     case "H": return 5;
     case "V": return 6;
     case "X": return 8;
     case "+": return 9;
     case "Y": return 10;
     case "k":;
     case "K": return 20;
     case "L": return 30;
     case "m":;
     case "M": return 40;
     case "n":;
     case "N": return 50;
     case "$": return 60;
     case "O": return 70;
     case "p":;
     case "P": return 80;
     case "c":;
     case "C": return 90;
     case "q": return 100;
     case "R": return 200;
     case "S": return 300;
     case "T": return 400;
     default: return 0;

   function computeValue(str) {
    var ans = 0;
    for(var i = 0; i < str.length; i++) {
     ans += getKeyValue_h(str.charAt(i));
    return ans;
function Process(){
  var frm = document.getElementById("form1");
  var x = Number(frm.hOutput.value);
  var remainder = (x % 22);
  if (remainder==0) {remainder=22;}
  alert("( " + x + " % 22 ) = SPOKE " + remainder)
  <style type="text/css">
<%'<form id="form1" action="" onsubmit="">
'Enter a number to determine which SPOKE it belongs to:
'    <input type="text" name="t1"/>
'    <input type="button" value="SPOKE" onclick="Process()"/>
  <form id="form1" action="javascript:void(0)">
    <textarea          name="hInput"  id="hInput"  onkeyup="hOutput.value = computeValue(hInput.value, 'h');" rows="9" cols="64" class="onLoad"></textarea><br />
    <input type="reset" value="Clear" name="B2" />
    <input type="text" name="hOutput" id="hOutput" onkeyup="t1.value = Process()" class="onLoad"/>
    <input type="text" name="t1" id="t1" 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

All times are GMT -4. The time now is 10:40 AM.

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