...

View Full Version : a problem with a switch



valyii
11-05-2012, 04:15 PM
A function which allows the user to enter the day of the week as a number or string (i.e., 1=Monday, 2=Tuesday…..5= Friday), and displays the labs and lectures (including the times and locations) you have on that particular day.

i dont know how to make the swith so it ca read numbers and string...i mean for 1 and monday to do the same thing
(thanks for youre help in advance)

Philip M
11-05-2012, 04:32 PM
A function which allows the user to enter the day of the week as a number or string (i.e., 1=Monday, 2=Tuesday…..5= Friday), and displays the labs and lectures (including the times and locations) you have on that particular day.

i dont know how to make the swith so it ca read numbers and string...i mean for 1 and monday to do the same thing
(thanks for youre help in advance)

It would make more sense for the user to select the day of the week from a select list. Then you avoid verification problems.

<option value = 0> Sunday </option>
<option value = 1> Monday </option>

Quizmaster: What D do you call a native of Denmark?
Contestant: Dutch

WolfShade
11-05-2012, 04:34 PM
Use a SELECT, set the values as desired, and give it an onchange event handler, passing the value, not the text (ie, <option value=1>Monday</option>)

function name(arg){
switch(arg){
case 1:
blah blah blah;
break;
case 2:
blah blah blah;
break;
...
case 7:
blah blah blah;
break;
}

WolfShade
11-05-2012, 04:34 PM
AH.. Philip beat me to it! GMTA



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum