Welcome to WebmasterWorld Guest from 3.227.233.55

Forum Moderators: open

Message Too Old, No Replies

Select controls and empty values

Javascript problems

     
5:10 pm on Aug 27, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 0


Ok first I will describe what I am trying to accomplish:

I have 3 form controls. The first(A) is a select drop down. The second(B) is another select, which is disabled until the first has a value. The third(C) is a text box which is disabled until the first 2 selects have a value.

A is the number of weeks, B is a start date, and C is an end date.

The idea is that the user selects a value in A which causees B to be populated with values and enabled. The user then selects a value in B which causes a text value to be displayed in C.

Make sense? :)

The problem I have is that initialy I would like the selects to be 'blank' meaning the first 'option' in the select control wont have any text. This is easy enough to do but it becomes a problem because it leaves open the posiblity that the user can re-select the 'blank' option, which of course screws up the javascript that calculates the value to be displayed in C.

Hopefully that makes my problem clear, its a little long winded ;)

Any help would be appreciated.

Thanks

2:39 am on Aug 28, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 21, 2002
posts:977
votes: 0


How about using a validation function called by the onChange event. If the user changes it to blank, give them a friendly alert message and put the focus back in the blank control.
4:33 am on Aug 28, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:July 26, 2003
posts:881
votes: 0


You can also set the blank to the same value as the first option, just don't show any text in it...

<option value="1" selected></option>

Jordan

5:05 am on Aug 28, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:June 23, 2003
posts:145
votes: 0


Only just learning javascript but can't you put an "if" in the appropriate place in your code to detect a nul value and an alert box.
4:59 pm on Aug 28, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:May 16, 2003
posts:592
votes: 0


Thanks guys. Alert boxes arent an option as they are confusing/annoying for the user I will see how MonkeeSage's method works out.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members