Click here to Skip to main content
15,909,193 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: I want to count number of hits on my sitee Pin
KrIstOfK10-May-06 21:29
KrIstOfK10-May-06 21:29 
AnswerRe: I want to count number of hits on my sitee Pin
chinnasrihari11-May-06 0:10
chinnasrihari11-May-06 0:10 
QuestionNumber of working days between 2 dates (PLZ Help) Pin
Programm3r9-May-06 20:22
Programm3r9-May-06 20:22 
AnswerRe: Number of working days between 2 dates (PLZ Help) Pin
Michael P Butler9-May-06 21:13
Michael P Butler9-May-06 21:13 
GeneralRe: Number of working days between 2 dates (PLZ Help) Pin
Programm3r10-May-06 20:52
Programm3r10-May-06 20:52 
QuestionIP address of a machine consuming a web service Pin
Saji Karekatt9-May-06 15:59
Saji Karekatt9-May-06 15:59 
QuestionProblem with Loading XML Unicode(iso-8859-1) file into DOM Pin
bhavani_ge9-May-06 13:17
bhavani_ge9-May-06 13:17 
Questionjavascript switch statement - weird behavior (I think) Pin
Jesse Evans9-May-06 8:32
Jesse Evans9-May-06 8:32 
Folks,

I have a web database app that uses an htm page as the user interface and calls an asp page to interact with my database. I've designed this so that the htm page calls the asp with a parameter that selects which function to run and I'm doing so using a switch statement as the first thing which gets executed when the asp page loads:
<br />
<script language=javascript runat=server><br />
var szMethod = Request.Querystring ("Method");<br />
<br />
switch (szMethod)<br />
{<br />
   case "QueryUserRecs":<br />
      QueryUserRecs ();<br />
      break;<br />
      <br />
   case "AppendTicket":<br />
      AppendTicket ();<br />
      break;<br />
      <br />
   default:<br />
      break;<br />
}<br />

Looks ok, right? The strange thing is, this only works if I make the szMethod variable a String object, convert it to upper case and set the switch case values upper case as well (lower case also works):
<br />
<script language=javascript runat=server><br />
var szMethod = new String (Request.Querystring ("Method"));<br />
<br />
switch (szMethod.toUpperCase ())<br />
{<br />
   case "QUERYUSERRECS":<br />
      QueryUserRecs ();<br />
      break;<br />
      <br />
   case "APPENDTICKET":<br />
      AppendTicket ();<br />
      break;<br />
      <br />
   default:<br />
      break;<br />
}<br />

If I don't code it this way the switch statement falls through to the default case. I've inserted Response.Write's to be sure I'm coming in with the proper Method values and it looks correct on paper, but it just doesn't work. Funny thing #2: using mixed case works if the switch statement is in the same page/module as the function which calls it:
<br />
function AddMOTD (which)<br />
{<br />
switch (which)<br />
{<br />
case "Global":<br />
// do the Global thing...<br />
break;<br />
			<br />
case "Product":<br />
// do the Product thing...<br />
break;<br />
			<br />
case "User":<br />
// Do the User thing<br />
break;<br />
}<br />
}<br />
...<br />
<button name="btnAddGlobalMOTD" disabled onclick="AddMOTD('Global')">Add/Update</button></td>	<br />

[Edit: the event assigned to AddMOTD() is onclick but CP has replaced it with removed (probably a safety issue). [/Edit]

Right now I have a method that works, but it seems kludgy.
Any clues as to what's going on?

'til next we type...
HAVE FUN!! -- Jesse

-- modified at 14:34 Tuesday 9th May, 2006
AnswerRe: javascript switch statement - weird behavior (I think) Pin
Guffa9-May-06 12:04
Guffa9-May-06 12:04 
GeneralRe: javascript switch statement - weird behavior (I think) Pin
Jesse Evans10-May-06 7:27
Jesse Evans10-May-06 7:27 
AnswerRe: javascript switch statement - weird behavior (I think) Pin
Guffa10-May-06 9:42
Guffa10-May-06 9:42 
GeneralRe: javascript switch statement - weird behavior (I think) Pin
Jesse Evans10-May-06 11:21
Jesse Evans10-May-06 11:21 
Questionhow to create multiple selection listbox with checkbox(listcheckbox) in asp Pin
virendra_sw9-May-06 3:40
virendra_sw9-May-06 3:40 
QuestionWeb Chart Control Pin
hi_arv8-May-06 23:38
hi_arv8-May-06 23:38 
QuestionIE 7 Beta 3 Pin
Brendan Vogt8-May-06 22:12
Brendan Vogt8-May-06 22:12 
AnswerRe: IE 7 Beta 3 Pin
Guffa9-May-06 0:35
Guffa9-May-06 0:35 
QuestionHow to use msiHiddenProperties property for MSI. I am using VS.NET IDE [Need Help] Pin
Kumar Shanmugam8-May-06 20:04
professionalKumar Shanmugam8-May-06 20:04 
QuestionFooter Problems! (5 Side by Side DIV elements, at bottom of the page) Pin
chasetoys8-May-06 12:31
chasetoys8-May-06 12:31 
QuestionWeb Package Pin
yedy8-May-06 1:13
yedy8-May-06 1:13 
QuestionIIS metabase Error Pin
hasan19828-May-06 1:00
hasan19828-May-06 1:00 
QuestionHow to draw a rectangle using Javascript? Pin
KaKa'7-May-06 23:13
KaKa'7-May-06 23:13 
AnswerRe: How to draw a rectangle using Javascript? Pin
CWIZO9-May-06 0:45
CWIZO9-May-06 0:45 
QuestionExecuting parent window's function Pin
metbinu2003@yahoo.com7-May-06 22:02
metbinu2003@yahoo.com7-May-06 22:02 
AnswerRe: Executing parent window's function Pin
CWIZO7-May-06 22:08
CWIZO7-May-06 22:08 
Questionconnecting to MS Access database with JavaScript Pin
mhmo7-May-06 6:46
mhmo7-May-06 6:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.