0
   

Javascript if/then for input text

 
 
Reply Fri 22 Feb, 2013 08:58 am
Hello,
I am a newbie to Javascript.
Is there a way to have a div to display block/none depending on the number typed in a text field?

Example: (simplified code)
<input type="text"/>
<div class=showhide">
<p>Show or hide</p>
</div>

I need the div.showhide to display:none; if "1" is typed in the input text field, and if "2" is typed in the text field, then div.showhide needs to display:block;

1 = hide
2 = show

Something like:
If the value = 1
Then display div.showhide none
Else the value = 2
Then display div.showhide block

I have searched for code and similar ways to do this, but found no luck.
Any help is greatly appreciated!

Thank you
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Question • Score: 0 • Views: 734 • Replies: 0
No top replies

 
 

Related Topics

 
  1. Forums
  2. » Javascript if/then for input text
Copyright © 2025 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 05/14/2025 at 07:54:43