Question : looking for comments on this switch statement

First off this is going on a site with hundreds of pages and I am looking to include the iframe code on only a select few pages, otherwise it shouldn't show anything.  So for a large number xxx78 will be undefined.

So most of what I am looking for does anyone have any suggestions to do this better or cleaner?  Should I even bother with checking if xxx78 is undefined?  etc

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
var xxx78 = rM7.rPU[rm_OldID];
		        if (xxx78 != undefined) {
		            switch(xxx78) {
                        case "Go Away From Here":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=1\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "Blah Blah 23":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=3\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10001-Blah Bark":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=2\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10002-Gloow Too":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=5\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10004-Bring Back":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=9\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10007-Flume":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=4\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10003-Fortnight":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=7\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10009-Conges":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=6\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                        case "FlimFlam-Coord:10011-Congei":
                            document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=8\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
                            break;
                    }
		        }

Answer : looking for comments on this switch statement

And since I spy that the only difference between the various switch statements are a single parameter in the URL of the created IFRAME, I would do it like this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
function GetIFrameParam(value) {
  switch(value) {
    case "Go Away From Here": 
      return 1;
    case "Blah Blah 23":
      return 3;
    case "FlimFlam-Coord:10001-Blah Bark":
      return 2;
    case "FlimFlam-Coord:10002-Gloow Too":
      return 5;
    case "FlimFlam-Coord:10004-Bring Back":
      return 9;
    case "FlimFlam-Coord:10007-Flume":
      return 4;
    case "FlimFlam-Coord:10003-Fortnight":
      return 7;
    case "FlimFlam-Coord:10009-Conges":
      return 6;
    case "FlimFlam-Coord:10011-Congei":
      return 8;
    default:
      return -1;
  }
}

/*
  And the original code would the be
*/
var iframeParam = GetIFrameParam(rM7.rPU[rm_OldID]);

if(iframeParam != -1)
  document.write("<IFRAME SRC=\"http://www.domain.com/bin/gr.cgi?pit=3&lit=197fH5C3&goid=" + iframeParam + "\" FRAMEBORDER=\"0\" SCROLLING=\"NO\" WIDTH=\"0\" HEIGHT=\"0\"></IFRAME>");
Random Solutions  
 
programming4us programming4us