New Posts  All Forums:Forum Nav:

JavaScript Question

post #1 of 6
Thread Starter 
I need some help on this one, as soon as possible. I was asked a question about a code and I dont know how to answer it. Hopefully someone here does.

I was asked why do I need to have the menuTabs array in this problem. Ive been scratching my head trying to figure out why but I dont see the need for it.


Code:
window.onload = init;



function init() {
   var menuTabs = new Array();
   var allSelect = document.getElementsByTagName("select");

   for (var i=0; i< allSelect.length; i++) allSelect[i].onchange=loadLink;
}

function loadLink() {
   sIndex = this.selectedIndex;
   location.href = this.options[sIndex].value;
}
I included the whole website and js file in case you needed to look at this. If you can help I will owe you one.
Edited by Warblade31 - 6/10/11 at 12:10am
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
post #2 of 6
Downloaded the zip and the only place menuTabs Array even shows up is what you pasted. It gets declared as a local Array and then is never called within the init() function so I don't see why you would need it.

A trick question??
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
post #3 of 6
Thread Starter 
I thought so too but they asked for me to provided a page reference in my book and why you would use it. Its a weird question but they want an answer today or tomorrow so I in a bit of a jam here. Could it be used for the left hand menu at some point or is it referencing something on the page?
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
post #4 of 6
menuTab is a local variable of the init() function so it's not possible to reference it from outside.

Simply doing a Find All for menuTab on all the files brings up that single declaration.
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
Main PC
(13 items)
 
  
CPUMotherboardGraphicsRAM
i5 2500k Asus Maximus IV Gene-Z MSI 6950 2gb Unlocked Ref GSkill Ripjaws X 8GB CL8 
Hard DriveOSMonitorKeyboard
Crucial M4 128GB Windows 7 Ult Samsung 24" ToC Das Professional Silent 
PowerCaseMouse
Seasonic X750 Corsair 650d Logitech G700 
  hide details  
Reply
post #5 of 6
Thread Starter 
Ok thanks Jonowxeno, + rep for your help. It must be a trick question then. Hopefully it is though otherwise Ill be losing points.
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
AMD Falcon
(14 items)
 
  
CPUMotherboardGraphicsRAM
AMD 1090T x6 @4.2 (1.45v - 1.5v FullLoad) ASUS CrossHair IV Formula (2880 NB @ 1.3v XFX Radeon HD 6870 12gb GSKILL Ripjaws @1700 9-8-8-24 2T 
Hard DriveOptical DriveOSMonitor
CRUCIAL SSD 128G | 2x 1T WD SATAIII Basic DVD Burner Windows 7 Professional 64bit ASUS VE276Q 27 inch 
KeyboardPowerCaseMouse
WASD Keyboard CORSAIR HX Series 750W NZXT Phantom White and Red version Albino Rat 7 Mouse 
Mouse PadOther
XFX Warpad apple ipad 
  hide details  
Reply
post #6 of 6
Yep, it is not used and is not needed. Probably a trick question.
White TITAN
(16 items)
 
   
CPUMotherboardGraphicsRAM
intel core i7-3770k Asus Z77 Sabertooth EVGA GTX 780 SC ACX Corsair Dominator Platinum 16GB (2x8GB) 
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro  WD Black Crucial M4 LG Blueray 
CoolingOSMonitorPower
Swiftech H220 (Stock cooler on while RMA :( ) Windows 7 64bit Dell 2311h Ultrasharp x 2 Corsair AX850 
CaseMouseMouse PadAudio
Fractal Design Define R4 White (w/ Window) Logitech G700 Razer Control Edition Sound Blaster ZxR 
CPUMotherboardGraphicsRAM
Intel 980x Asus Rampage iii Extreme EVGA GTX580 SLI Patriot Viper Xtreme 12GB DDR3 2000 (PC3 16000) 
Hard DriveHard DriveHard DriveOptical Drive
120GB Corsair Force Series 3 SSD WD Caviar Black 640GB Crucial M4 128GB SSD LG Black Blu-ray Drive SATA Model UH12LS28 
CoolingCoolingCoolingCooling
XSPC RX360 and RX120 Rads Watercool HeatKiller 3.0 Limited Edition Black ... XSPC Dual Bay Res with Swiftech MCP655 Pump Silver Shining Bitspower Compression Fittings 
CoolingCoolingCoolingCooling
PrimoFlex Pro LRT Black Tubing -1/2in. ID X 3/4in. 3x Gentle Typhoon 120mm Fan 1850RPM (AP-15)  1x Noiseblocker NB-BlackSilentPro PL-2 120mm Ul... Koolance VID-NX580 Full Cover GPU Waterblock x2 
OSMonitorKeyboardPower
Windows 7 Home Premium x64 Dell U2311 Ultrasharp x2 Max Keyboard Nighthawk X8 Semi-Custom - Mechani... Antec High Current Gamer 900W 
CaseMouseMouse PadAudio
Xigmatek Elysium Black Logitech G700 Razer Goliathus Creative Sound Blaster Recon3D Fatal1ty Pro 
  hide details  
Reply
White TITAN
(16 items)
 
   
CPUMotherboardGraphicsRAM
intel core i7-3770k Asus Z77 Sabertooth EVGA GTX 780 SC ACX Corsair Dominator Platinum 16GB (2x8GB) 
Hard DriveHard DriveHard DriveOptical Drive
Samsung 840 Pro  WD Black Crucial M4 LG Blueray 
CoolingOSMonitorPower
Swiftech H220 (Stock cooler on while RMA :( ) Windows 7 64bit Dell 2311h Ultrasharp x 2 Corsair AX850 
CaseMouseMouse PadAudio
Fractal Design Define R4 White (w/ Window) Logitech G700 Razer Control Edition Sound Blaster ZxR 
CPUMotherboardGraphicsRAM
Intel 980x Asus Rampage iii Extreme EVGA GTX580 SLI Patriot Viper Xtreme 12GB DDR3 2000 (PC3 16000) 
Hard DriveHard DriveHard DriveOptical Drive
120GB Corsair Force Series 3 SSD WD Caviar Black 640GB Crucial M4 128GB SSD LG Black Blu-ray Drive SATA Model UH12LS28 
CoolingCoolingCoolingCooling
XSPC RX360 and RX120 Rads Watercool HeatKiller 3.0 Limited Edition Black ... XSPC Dual Bay Res with Swiftech MCP655 Pump Silver Shining Bitspower Compression Fittings 
CoolingCoolingCoolingCooling
PrimoFlex Pro LRT Black Tubing -1/2in. ID X 3/4in. 3x Gentle Typhoon 120mm Fan 1850RPM (AP-15)  1x Noiseblocker NB-BlackSilentPro PL-2 120mm Ul... Koolance VID-NX580 Full Cover GPU Waterblock x2 
OSMonitorKeyboardPower
Windows 7 Home Premium x64 Dell U2311 Ultrasharp x2 Max Keyboard Nighthawk X8 Semi-Custom - Mechani... Antec High Current Gamer 900W 
CaseMouseMouse PadAudio
Xigmatek Elysium Black Logitech G700 Razer Goliathus Creative Sound Blaster Recon3D Fatal1ty Pro 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding