473,414 Members | 1,878 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,414 software developers and data experts.

hide/show text area with textEditor depends on dropdown value

123 100+
I use the NicEdit(www.nicedit.com) text-editor on my Text Area which is working and the below code to hide and show text area after selecting a value in the drop down it will show the text area but this is what i need help with:

1) i want the text area to show even before you select any value from the drop down.

2) i want the Text editor(NicEdit) to show on all the text area after selecting a value from the drop down to show the text area.

Js For Text-editor(Nicedit):
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="js/nicEdit.js"></script>
  2. <script type="text/javascript">
  3.     bkLib.onDomLoaded(function() {
  4.         new nicEditor({maxHeight : 200}).panelInstance('area');
  5.     });
  6. </script>
  7.  
Js to hide and show text area:
Expand|Select|Wrap|Line Numbers
  1.    <script type="text/javascript">
  2.         function showHide() 
  3.         {
  4.             if(document.getElementById("color_dropdown").selectedIndex == 1) 
  5.             {
  6.                 document.getElementById("hidden1").style.display = ""; // This line makes the DIV visible
  7.             } 
  8.             else {            
  9.                 document.getElementById("hidden1").style.display = "none"; // This line hides the DIV
  10.             }
  11.  
  12.             if(document.getElementById("color_dropdown").selectedIndex == 2) 
  13.             {
  14.                 document.getElementById("hidden2").style.display = ""; // This line makes the DIV visible
  15.             } 
  16.             else {            
  17.                 document.getElementById("hidden2").style.display = "none"; // This line hides the DIV
  18.             }
  19.  
  20.             if(document.getElementById("color_dropdown").selectedIndex == 3) 
  21.             {
  22.                 document.getElementById("hidden3").style.display = ""; // This line makes the DIV visible
  23.             } 
  24.             else {            
  25.                 document.getElementById("hidden3").style.display = "none"; // This line hides the DIV
  26.             }
  27.         }
  28.     </script>
  29.  
Html drop down:
Expand|Select|Wrap|Line Numbers
  1. <select name="menu"  id="color_dropdown" onchange="showHide()"> 
  2.                                                 <option>Select Meun</option>
  3.                                                 <option>One</option>
  4.                                                 <option>Two</option>
  5.                                                 <option>Three</option>
  6. </select>   
  7.  
  8. <textarea id="hidden1" name="area" display:none;"   id="area">ggggggggggggggggg</textarea>
  9. <textarea id="hidden2" name="area"  display:none;" id="area">hhhhhhhhhhhhhhhhh</textarea>
  10. <textarea id="hidden3" name="area"  display:none;"  id="area">yyyyyyyyyyyyyyyyy</textarea>
  11.  
Jul 13 '13 #1
1 3803
Sherin
77 64KB
Try This Code

Expand|Select|Wrap|Line Numbers
  1. <html lang="en">
  2. <head>
  3. <meta charset="utf-8">
  4. <title>jQuery Show Hide Elements Using Select Box</title>
  5. <style>
  6.     .box{
  7.         color: #fff;
  8.         padding: 20px;
  9.         display: none;
  10.         margin-top: 20px;
  11.     }
  12.     .red{ background: #ff0000; }
  13.     .green{ background: #228B22; }
  14.     .blue{ background: #0000ff; }
  15. </style>
  16. <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  17. <script>
  18. $(document).ready(function(){
  19.     $("select").change(function(){
  20.         $(this).find("option:selected").each(function(){
  21.             var optionValue = $(this).attr("value");
  22.             if(optionValue){
  23.                 $(".box").not("." + optionValue).hide();
  24.                 $("." + optionValue).show();
  25.             } else{
  26.                 $(".box").hide();
  27.             }
  28.         });
  29.     }).change();
  30. });
  31. </script>
  32. </head>
  33. <body>
  34.     <div>
  35.         <select>
  36.             <option>Choose Color</option>
  37.             <option value="red">Red</option>
  38.             <option value="green">Green</option>
  39.             <option value="blue">Blue</option>
  40.         </select>
  41.     </div>
  42.     <div class="red box">You have selected <strong>red option</strong> so i am here</div>
  43.     <div class="green box">You have selected <strong>green option</strong> so i am here</div>
  44.     <div class="blue box">You have selected <strong>blue option</strong> so i am here</div>
  45. </body>
  46. </html>
Nov 27 '20 #2

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

Similar topics

4
by: jerryyang_la1 | last post by:
I've found this script that allows be to hide/show form elements.. <script language="JavaScript"><!-- var toggle = true; function show(object) { if (document.layers && document.layers)...
2
by: UJ | last post by:
Is there a way with a asp:checkbox to run a JavaScript to display/hide text/input on the screen without doing a postback? I also need to be able to access the stuff at the server so I need to...
5
by: srampally | last post by:
I need the capabilty to hide/show a selection list, just the way its done at http://www.lufthansa.com (place the cursor over "Group Companies"). However, I am looking for a javascript that is much...
4
by: devine | last post by:
Hi All, I am VERY new to Javascript. I have been provided with some code, which will enable me to hide/show a text area and change a submit button dependant on a check box. <!DOCTYPE html...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
2
maxamis4
by: maxamis4 | last post by:
I have a text box that holds a value of 300 how do I make it show $ 300.00, not to mention their are multiple records that have 1200, 900, and I want them to display with the dollar sign.
1
by: stuy2k | last post by:
Hi im trying to make a section of text appear and disapear by clicking the question find example at - http://www.yellowtruck.co.uk/pascoes2/Untitled-4.html the java script i am using is found...
1
by: Kirthikaiitm | last post by:
Hi, I am new to Javascript. I want to change the dropdown box to text area on clicking the link provided below Dropdown box and i want to get the value entered in text box. Then i have to...
1
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the...
10
by: Luxury17 | last post by:
I know this has been posted and asked about many times, but I still cannot seem to find an answer that fits my situation. I am pretty new with javascripting, and have been teaching myself as the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.