473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Key Stoke not registering

KeredDrahcir
426 256MB
I've have two divisions and I have a question and if the answer is yes I want to hide the first division and show the second. If the answer is anything else I want to hide them both.
Expand|Select|Wrap|Line Numbers
  1. <div id="title" style="display: block; width: 900px; height: 475px; margin: 0 auto;">
  2.   some content
  3. </div>
  4. <div id="instructions" style="display: none; width: 900px; height: 475px; margin: 0 auto;">
  5.   other content
  6. </div>
  7.  
Since they answer can only be yes or no, I'm using an onkeydown function to sort out the display options.

Expand|Select|Wrap|Line Numbers
  1. <input type="text" name="instruction" id="instruction" onkeydown="toggle_visibility()" style="width: 20px; border: 0; font-size: 14pt;"/>
  2.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.     <script type="text/javascript">
  3.     <!--
  4.         function toggle_visibility() {
  5.            var a = document.getElementById('title');
  6.            var b = document.getElementById('instructions');
  7.            if (document.story.instruction.value == "y")
  8.            {
  9.              a.style.display = 'none';
  10.              b.style.display = 'block';
  11.            }
  12.            else
  13.            {
  14.                 a.style.display = 'none';
  15.              b.style.display = 'none';
  16.            }
  17.         }
  18.     //-->
  19.     </script>
When I run it, all that happens is the both divisions are hidden whatever I type. If I hide the code in the else then press 'y' nothing happens but if I then delete it, it show the correct division. Am I missing something here?
May 12 '13 #1
3 1431
Rabbit
12,516 Expert Mod 8TB
Because the key has just been pressed, the value of the textbox has not yet been updated with the newly pressed key. Instead you need to check the event object to see what key was just pressed.

Also, I don't see the point of the first div, it will never ever be displayed so why have it at all?
May 12 '13 #2
KeredDrahcir
426 256MB
The first div displays when you load the page. The keystroke is there to switch the divs over.
May 12 '13 #3
Rabbit
12,516 Expert Mod 8TB
Ok, my solution still applies.
May 13 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bob | last post by:
Hi, I am having trouble registering a row from a mysql query so far I have the mysql part working : while ( $val = mysql_fetch_array( $result )) { print("<tr><td>$val</td> <td>$val</td>...
0
by: Sylwia | last post by:
Hi! I have the following problem :( After registering the "PythonService.exe" executable... C:\Python23\Lib\site-packages\win32>PythonService.exe -register I got the following error...
1
by: Kelly G. | last post by:
I need to register a Vb DLL under restricted acess privilages please provide me a solution. Here is the complete issue: I building a MSI using Vs.net ,One of the Dll's is Vb Component ( A shim...
6
by: Daniel Bass | last post by:
The scenario: ------------- I've created a simple COM object according to a tutorial I found: http://www.csharphelp.com/archives/archive281.html It automatically creates a Type Library...
6
by: ian | last post by:
Hi All I have a DLL (nahd.dll) that has been supplied to me will a PBX phone system. According to the documentation it is to allow developers to write there own applications to monitor the...
0
by: Dan Bass | last post by:
One day, out of the blue, anything COM interop related stopped building. When building any project (VB / C#) that has a COM interop interface (my own home grown projects, or a Visual Studio .Net...
2
by: glenn | last post by:
I have written a COM Server in C# and its working perfectly. I am not ready to deploy to client computers to begin the real testing and am now wondering how to perform. The part that confuses me...
13
by: noone | last post by:
consider the following problem: You have a C style library and API that uses callbacks to implement functionality. Examples of this are X11 API, OpenGL/GLUT...The List goes on. The power of...
2
by: linuxfedora | last post by:
I have written a C# program which has an activeX control (abc.ocx) in Visual Studio 2005, and used the setup and deployment project to create an setup.exe and setup.msi that act as an installer. ...
0
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.