• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

Object Expected error

I'm getting an Object Expected error on line 220 in my code and I can't figure out why... Am I doing my button wrong somehow?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>White Glove Preday Check Email Generator</title>
 
 <script language="javascript" type="text/javascript">
 
 Function asia() {
 
  if (document.Backups.value == "Green")
 	{alert ("Yo!")}
	;
	
 }
 </script>
 
</head>
<body>
<center><b>White Glove Preday Check Email Generator</b></Center>
<br><p>
<table border="1">
  <tr><!-- Row 1 -->
     <td>Antrim/Zavacor</td><!-- Col 1 -->
     <td><select name="Ant_Zav" onChange="document.getElementById('Ant_Zav_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="Ant_Zav_Explain" style="display: none">
		Explanation: <input type="textbox" name="Ant_Zav_Explained" size="32"/>
		</div>
	</td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 2 -->
     <td>Backups</td><!-- Col 1 -->
     <td><select name="Backups" onChange="document.getElementById('Backups_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="Backups_Explain" style="display: none">
		Explanation: <input type="textbox" name="Backups_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 3 -->
     <td>Data Extract/Loader</td><!-- Col 1 -->
     <td><select name="DEL" onChange="document.getElementById('DEL_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DEL_Explain" style="display: none">
		Explanation: <input type="textbox" name="DEL_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 4 -->
     <td>Data Transfer</td><!-- Col 1 -->
     <td><select name="DT4" onChange="document.getElementById('DT4_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DT4_Explain" style="display: none">
		Explanation: <input type="textbox" name="DT4_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 5 -->
     <td>Database - DSM</td><!-- Col 1 -->
     <td><select name="DSM" onChange="document.getElementById('DSM_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DSM_Explain" style="display: none">
		Explanation: <input type="textbox" name="DSM_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 6 -->
     <td>Database - Informix</td><!-- Col 1 -->
     <td><select name="INF" onChange="document.getElementById('INF_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="INF_Explain" style="display: none">
		Explanation: <input type="textbox" name="INF_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 7 -->
     <td>Database - Oracle</td><!-- Col 1 -->
     <td><select name="ORA" onChange="document.getElementById('ORA_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="ORA_Explain" style="display: none">
		Explanation: <input type="textbox" name="ORA_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 8 -->
     <td>FLR/Exacta</td><!-- Col 1 -->
     <td><select name="FLR" onChange="document.getElementById('FLR_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="FLR_Explain" style="display: none">
		Explanation: <input type="textbox" name="FLR_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 9 -->
     <td>LabLink</td><!-- Col 1 -->
     <td><select name="LAB" onChange="document.getElementById('LAB_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="LAB_Explain" style="display: none">
		Explanation: <input type="textbox" name="LAB_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 10 -->
     <td>Network</td><!-- Col 1 -->
     <td><select name="NET" onChange="document.getElementById('NET_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="NET_Explain" style="display: none">
		Explanation: <input type="textbox" name="NET_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 11 -->
     <td>QBS</td><!-- Col 1 -->
     <td><select name="QBS" onChange="document.getElementById('QBS_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="QBS_Explain" style="display: none">
		Explanation: <input type="textbox" name="QBS_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 12 -->
     <td>Server - INTEL</td><!-- Col 1 -->
     <td><select name="INTEL" onChange="document.getElementById('INTEL_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="INTEL_Explain" style="display: none">
		Explanation: <input type="textbox" name="INTEL_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 13 -->
     <td>Unix Servers</td><!-- Col 1 -->
     <td><select name="UNI" onChange="document.getElementById('UNI_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="UNI_Explain" style="display: none">
		Explanation: <input type="textbox" name="UNI_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 14 -->
     <td>Storage</td><!-- Col 1 -->
     <td><select name="STO" onChange="document.getElementById('STO_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="STO_Explain" style="display: none">
		Explanation: <input type="textbox" name="STO_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
</table>
<input type="button" value="press me" onClick="javascript:asia()"/>
</body>
</html>

Open in new window

0
Awake_in_naptown
Asked:
Awake_in_naptown
2 Solutions
 
jello024Commented:
Function asia()  
should be:
function asia()
0
 
jazzIIIloveCommented:
document.Backups.value is empty. Check for it.
0
 
TMarkham1Commented:
You may even need to go further than that... try replacing the whole asia function code with this:

function asia() {
   if (document.Backups.value == "Green")
   { 
      alert ("Yo!");
   }
 }

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
TMarkham1Commented:
Actually, I modified your HTML even further. I added an ID attribute to the Backups element, and modified the asia function as well. It works for me. Give it a shot.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>White Glove Preday Check Email Generator</title>
 
 <script language="javascript" type="text/javascript">
 
 function asia() {
 
  var sel = document.getElementById("Backups");
  if (sel.options[sel.selectedIndex].value == "Green")
     {
       alert("Yo!");
     }
	
 }
 </script>
 
</head>
<body>
<center><b>White Glove Preday Check Email Generator</b></Center>
<br><p>
<table border="1">
  <tr><!-- Row 1 -->
     <td>Antrim/Zavacor</td><!-- Col 1 -->
     <td><select name="Ant_Zav" onChange="document.getElementById('Ant_Zav_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="Ant_Zav_Explain" style="display: none">
		Explanation: <input type="textbox" name="Ant_Zav_Explained" size="32"/>
		</div>
	</td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 2 -->
     <td>Backups</td><!-- Col 1 -->
     <td><select id="Backups" name="Backups" onChange="document.getElementById('Backups_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="Backups_Explain" style="display: none">
		Explanation: <input type="textbox" name="Backups_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 3 -->
     <td>Data Extract/Loader</td><!-- Col 1 -->
     <td><select name="DEL" onChange="document.getElementById('DEL_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DEL_Explain" style="display: none">
		Explanation: <input type="textbox" name="DEL_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 4 -->
     <td>Data Transfer</td><!-- Col 1 -->
     <td><select name="DT4" onChange="document.getElementById('DT4_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DT4_Explain" style="display: none">
		Explanation: <input type="textbox" name="DT4_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 5 -->
     <td>Database - DSM</td><!-- Col 1 -->
     <td><select name="DSM" onChange="document.getElementById('DSM_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="DSM_Explain" style="display: none">
		Explanation: <input type="textbox" name="DSM_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 6 -->
     <td>Database - Informix</td><!-- Col 1 -->
     <td><select name="INF" onChange="document.getElementById('INF_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="INF_Explain" style="display: none">
		Explanation: <input type="textbox" name="INF_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 7 -->
     <td>Database - Oracle</td><!-- Col 1 -->
     <td><select name="ORA" onChange="document.getElementById('ORA_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="ORA_Explain" style="display: none">
		Explanation: <input type="textbox" name="ORA_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 8 -->
     <td>FLR/Exacta</td><!-- Col 1 -->
     <td><select name="FLR" onChange="document.getElementById('FLR_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="FLR_Explain" style="display: none">
		Explanation: <input type="textbox" name="FLR_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 9 -->
     <td>LabLink</td><!-- Col 1 -->
     <td><select name="LAB" onChange="document.getElementById('LAB_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="LAB_Explain" style="display: none">
		Explanation: <input type="textbox" name="LAB_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 10 -->
     <td>Network</td><!-- Col 1 -->
     <td><select name="NET" onChange="document.getElementById('NET_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="NET_Explain" style="display: none">
		Explanation: <input type="textbox" name="NET_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 11 -->
     <td>QBS</td><!-- Col 1 -->
     <td><select name="QBS" onChange="document.getElementById('QBS_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="QBS_Explain" style="display: none">
		Explanation: <input type="textbox" name="QBS_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 12 -->
     <td>Server - INTEL</td><!-- Col 1 -->
     <td><select name="INTEL" onChange="document.getElementById('INTEL_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="INTEL_Explain" style="display: none">
		Explanation: <input type="textbox" name="INTEL_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 13 -->
     <td>Unix Servers</td><!-- Col 1 -->
     <td><select name="UNI" onChange="document.getElementById('UNI_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="UNI_Explain" style="display: none">
		Explanation: <input type="textbox" name="UNI_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
  <tr><!-- Row 14 -->
     <td>Storage</td><!-- Col 1 -->
     <td><select name="STO" onChange="document.getElementById('STO_Explain').style.display=this.options[this.selectedIndex].value!='Green'?'':'none'">
				  <option selected value="Green">Green</option>
				  <option value="Green*">Green*</option>
				  <option value="Yellow">Yellow</option>
				  <option value="Yellow*">Yellow*</option>
				  <option value="Red">Red</option>
				  <option value="Red*">Red*</option>
				  </select>
		<div id="STO_Explain" style="display: none">
		Explanation: <input type="textbox" name="STO_Explained" size="32"/>
		</div></td><!-- Col 2 -->
  </tr>
</table>
<input type="button" value="press me" onClick="javascript:asia()"/>
</body>
</html>

Open in new window

0
 
Awake_in_naptownAuthor Commented:
Essentially, yes it was that I used a capital F instead of a lowercase. Did a little fidgiting with the code and found that I needed a little more to it. Thanks guys, it's working now.
0
 
Awake_in_naptownAuthor Commented:
TMarkham1:

Well done with that code, it does make it a lot simpler. What i ended up doing was nesting the whole thing inside of a form, which was going to be the end result anyway. If I could  give you some points now I totally would! Sorry I missed your additions, you added them right as I was handing out the points :/
0
 
TMarkham1Commented:
No problem on the points... I just simplified the original true solutions anyhow. They right guys got the point I think.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now