Connecting Tech Pros Worldwide Forums | Help | Site Map

Javascript select box

Newbie
 
Join Date: Jan 2008
Posts: 1
#1: Jan 9 '08
hi
I have the following scenario..
i have a select box containing a list of times. on selecting one of them i am dispalying all the details pertaining to that selection. the list is prone to additions and hence might grow longer. So i would like the user to key in the values directly. So i have a text box and a button next to it on clicking which a dropdown appears. The user can directly enter the value in the text box or select one from the select box.I m setting the value of the text box to the value selected from the drop down in the latter case. In either cases, the value in the text box is taken for processing the request.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>xyz</title>
  3. <script>
  4.  
  5. function toggle(me){
  6.         if (me.style.visibility=="hidden"){
  7.             me.style.visibility="visible";
  8.             }
  9.         else {
  10.             me.style.visibility="hidden";
  11.             }
  12.         }
  13.  
  14.  
  15. </script>
  16. </head>
  17. <body onload="javascript:document.fsd.search.style.visibility = 'hidden'">
  18. <br><br><br><br>
  19. <form name="fsd" method="post" action="xyz.asp" >
  20. Enter RFC &nbsp;<input type="text" name="rfcname">&nbsp;<input type="button" title="Click to select a RFC" value="+" onclick="toggle(document.fsd.search)">&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Search">
  21. <br>
  22. &nbsp;&nbsp;&nbsp;&nbsp;
  23. <select name="search" style="width:140px;" onchange="javascript:document.fsd.rfcname.value = document.fsd.search.options[document.fsd.search.selectedIndex].value;document.fsd.search.style.visibility='hidden'">
what i would like to have is to make the list expand and contract on clicking the '+' button or someother work around to have the user enter the value or select from the dropdown.

thanks,
ramya

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Jan 9 '08

re: Javascript select box


To expand and contract, use style.display="block" and style.display="none" instead.
Reply