Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 11th, 2004, 12:32 AM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default show new textfield from drop-down list

hi all

i have a form with a drop-down list that allows the user to choose different categories or add a new category, if 'add a new category' is selected, a textfield will show up beside the drop-down list that allows the user to enter the new category

what do i have to do to achieve this???

Reply With Quote
  #2 (permalink)  
Old March 11th, 2004, 05:08 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You have two choices, either have a textfield always in the page but hidden until the user chooses 'add a new category' or create a new field from scratch using the DOM and insert it into the page. The first choice is probably easier. You may have to make some changes to support older browsers but this should work on IE and modern Mozilla types. In your list box have an onchange that calls showTextbox(this), I'm assuming the add new is the last choice in the listbox:
Code:
function showTextBox(Listbox)
{
  if (Listbox.selectedIndex == (Listbox.options.length - 1))
  /*To check on a specific value have if (Listbox.options[Listbox.selectedIndex].value == "<value here>")*/
  {
    document.getElementById("txtNewCategory").style.display = "";
  }
}
In the form have
Code:
<input type="text" id="txtNewCategory" name="txtNewCategory" style="display:none">
--

Joe
Reply With Quote
  #3 (permalink)  
Old March 11th, 2004, 09:16 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i see, i've managed to get it working

thanks joe

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down list ashu_gupta75 Excel VBA 1 October 15th, 2007 05:52 PM
show div over top of selects (drop downs) crmpicco Javascript How-To 10 February 14th, 2006 05:48 AM
show/hide text field from select (drop down) Gotaka4 Javascript 6 December 7th, 2005 05:44 AM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 6 March 18th, 2005 03:32 AM



All times are GMT -4. The time now is 01:23 AM.


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