Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 September 24th, 2004, 07:35 AM
Friend of Wrox
Points: 486, Level: 7
Points: 486, Level: 7 Points: 486, Level: 7 Points: 486, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: Athens, , Greece.
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default advanced listobox! Please Help

Hello Guyz...

I`d like to have a listbox with the follow values.
- English
- French
- German
- Other...

But when the user will select "Other..." I`d like to give him the option to write his own value in that listbox/textbox.
I`m quite new to JavaScript. So I`d be thankful if someone could give me the script to do that!

Thank you in advance!
Reply With Quote
  #2 (permalink)  
Old September 24th, 2004, 01:27 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

I suggest doing something like this:

<form id='form1' [other attributes]>
<select name='lang' onchange='checkIfOther(this.options[this.selectedIndex].value,this)'>
<option value='english'>english</option>
<option value='french'>french</option>
<option value='german'>german</option>
<option value='add'>add...</option>
</select>
<input type='submit' value='go'/>
</form>
<script type='text/javascript'>
function checkIfOther(lang,sel)
{
    if(lang=="add") {
    language = prompt('enter your language:','');
    if(language!==false)
    {
        sel.options.length++;
        sel.options[sel.options.length].value=language;
        sel.options[sel.options.length].text=language;
    }
}
}
</script>

HTH!

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #3 (permalink)  
Old September 27th, 2004, 01:19 AM
Friend of Wrox
Points: 486, Level: 7
Points: 486, Level: 7 Points: 486, Level: 7 Points: 486, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: Athens, , Greece.
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It`s quite good. Thank you for your reply!

But it`s not working fine... because when the user insert`s a language on the menu the value in the listbox is invisible.
Reply With Quote
  #4 (permalink)  
Old September 28th, 2004, 03:30 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

What exactly do you mean? It just disappears? Sounds like IE to me :-)

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #5 (permalink)  
Old September 29th, 2004, 01:49 AM
Friend of Wrox
Points: 486, Level: 7
Points: 486, Level: 7 Points: 486, Level: 7 Points: 486, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: Athens, , Greece.
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok... probably is IE fault or... I don`t know what`s wrong! Thank you for your reply! ;)
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
Is this forum too advanced for me? Randy Visual Basic 2008 Essentials 9 June 11th, 2008 08:49 PM
Where are the Advanced button? micror BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 7th, 2006 07:28 AM
Looking for advanced CSS dimo414 BOOK: Professional CSS: Cascading Style Sheets for Web Design 0 May 29th, 2006 10:57 PM
Advanced bitmap help UsrNm C++ Programming 1 September 13th, 2004 09:49 AM
advanced search Moharo Pro PHP 1 February 2nd, 2004 04:43 PM



All times are GMT -4. The time now is 09:30 AM.


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