Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Error referring to form field

Avatar of JJ123
JJ123 asked on
JavaScript
4 Comments1 Solution397 ViewsLast Modified:
I have some JavaScript that I can't seem to get to work. I will insert my code to show you what I am doing. The commented part seems to be the problem although I could definately be wrong. As soon as I uncomment them, I am getting an error 'object expected'. Otherwise the alert works fine.

here is the functions

var leaderArray = new Array();
<?PHP
$query = "SELECT * FROM managers order by name";    
$result = mysql_query($query);
while( $row = mysql_fetch_array($result) )
{  
       $query2 = "SELECT * FROM managers WHERE name = '".$row['name']."'";
       $result2 = mysql_query($query2);      
       echo "leaderArray[".$row['id']."] = new Array();\n";    
       while( $row2 = mysql_fetch_array($result2) ){
              echo "leaderArray[".$row['id']."].push('".$row2['leader']."');\n";          
      }
}
?>  

function Fill_Sub(inputManager) {
alert(inputManager);
//var lead = document.new.building;    
//mgr_leader.options.length=0;  

//for(var no=0;no<leaderArray[inputManager].length;no++)//{    
//mgr_leader.options[leader.options.length] = new Option(leaderArray[inputManager][no],leaderArray[inputManager][no]);    
//}      
}

Here is the fields in the form:
<tr><td width="95">Manager:</td>
<td><select name='manager' class='ta' onchange="Fill_Sub(this.options[this.selectedIndex].value);">
<option selected><?php echo $manager ?></option>
<?php
$query = "SELECT * FROM managers ORDER BY name";
$result = mysql_query($query) or die(mysql_error());
for($i=0;$i<mysql_numrows($result);$i++)
{
      $manager = mysql_fetch_array($result);
      ?>
      <option value="<?php echo $manager['id'] ?>"><?php echo $manager['name'] ?></option>
      <?php
}
?>
</select></td>
<td>Senior Manager:</td>
<td><select name='mgrleader' class='ta' value="<?php echo $leader ?>">
<option selected></option>
<option>Select a manager</option>
</select>
</td></tr>

I am sorry I don't have very many points to use on this question...
ASKER CERTIFIED SOLUTION
Avatar of JJ123
JJ123

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers