Hi, I have inherited a web front end to a SQL database. I am learning javascript but need a quick fix to something, and would be extremely grateful if anyone can help me out here.

I have a form on a page that uses drop down lists and buttons, the drop down list at the top of the form can be used on its own and a "view" button clicked to view the output in a table on another page. or the drop down boxes below can be used to populate the top drop down box, then again the "view" button can be used to view the results.

The thing is I wasn't bothered about the top drop down box being visible, because the other boxes can be used to make the selections, so you will see in the code that I made it invisible with css. However, I do need the "view" button, and this still works fine on the page without the user being able to see the top drop down box. BUT I just want that "view" button to appear under all the drop down boxes, at the bottom of the form rather than the top. but when i do this then i get a generic "Internal Server error", the page doesnt work how it should basically. I guess that this must be something to do with the ordering of the code, the code for the top drop down box must need to go before the others...

Can someone please demonstrate how I can achieve what I am trying to do? I really hope you understand what I am asking. Code below:

[CODE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ LANGUAGE="JScript" %>

<!--METADATA TYPE="typelib" uuid="00000206-0000-0010-8000-00AA006D2EA4" -->


<HTML>


<head>
<title>matrixformfilter</title>
<style type="text/css">
a{border:1px solid white;}
a:hover{border:1px solid purple;}
img{border:none;}</style>


<script type="text/javascript">
var theoptions = new Array();

function populatefiltered()
{
var froms=document.getElementById("fulllist");


var thedomainobj=document.getElementById("filterdomain")
var thedomain=thedomainobj.options[thedomainobj.selectedIndex].text

var thetrigramobj=document.getElementById("filtertrigram");
var thetrigram=thetrigramobj.options[thetrigramobj.selectedIndex].text
var thedatabaseobj=document.getElementById("filterdatabase");
var thedatabase=thedatabaseobj.options[thedatabaseobj.selectedIndex].text;
var thedaterangeobj=document.getElementById("filterdaterange");
var thedaterange=thedaterangeobj.options[thedaterangeobj.selectedIndex].text.replace(/^\s*/,"").replace(/\s*$/,"");


// set up theoptions on the first call
if (theoptions.length == 0)
{
for (var i=0;i< froms.length ;i++)
{
theoptions[i] = froms.options[i].text
}
}


// remove options
var toslength=froms.length
for (var i=0;i < toslength;i++)
{
froms.remove(0);
}

var iii = 10

for (var i=0;i< theoptions.length ;i++)
{
var thetext = theoptions[i];
var ss = thetext.split(" - ");
var compdb=ss[1].replace(/^\s*/,"").substring(3,10).replace(/\s*$/,"");
var compdr=ss[2].replace(/^\s*/,"").replace(/\s*$/,"");



if ( (thetext.substring(0,1) == thedomain || thedomain=="All") &&
(thetext.substring(4,7) == thetrigram || thetrigram=="All") &&
(compdb == thedatabase || thedatabase=="All") &&
(compdr == thedaterange || thedaterange=="All")
)
{
var opt=document.createElement('option');
opt.text=thetext;
froms.add(opt);
}
}
}
function populateall()
{
var thedomainobj=document.getElementById("filterdomain")
thedomainobj.selectedIndex=0

var thetrigramobj=document.getElementById("filtertrigram");
thetrigramobj.selectedIndex=0;
var thedatabaseobj=document.getElementById("filterdatabase");
thedatabaseobj.selectedIndex=0;
var thedaterangeobj=document.getElementById("filterdaterange");
thedaterangeobj.selectedIndex=0;

populatefiltered();
}
</script>




</HEAD>




<br />

<body style="background-image:url(images/bg.gif); background-repeat:repeat-x, repeat-y;">
<div style="background-color:White; width:90%; margin-right:auto; margin-left:auto; text-align:left; margin-top:3%; border:2px solid black;">
<div style="margin-right:auto; margin-left:300px; text-align:left; border: 10px;">
<br />





<%
var pageroles;
pageroles="CTOMatrix";
%>

<!--#include file="openconnection.asp"-->

<%
var oRssource;
var oRsdomain;

oCmd.CommandText = "select distinct nm.domain,cast(nm.source as char(10)),nm.daterangeindicator, " +
"convert(varchar(30),dri.startdatetime,121)," +
"convert(varchar(30),dri.enddatetime,121)" +
" from newmatrix nm ,newmatrixdaterange dri" +
" where nm.daterangeindicator = dri.daterangeindicator" +
" and nm.domain=dri.domain" +
" order by 1,2,3";
oRssource = oCmd.Execute();
%>



Please select required domain, source and date range <!--<A HREF="frontpage.asp"><font color="000033", size="4"><b>home</b></font></A>-->
<BR><br />
You can filter the list using the filter selection lists and then click <b>"Show Filtered List"</b> followed by <b>"View"</b><br><br>

(The Source drop down box displays the filtered selections from the further four drop down boxes below it.)
<br />
<BR>
<table border="0">
<FORM ID="matrixformfilter" ACTION ="matrix.asp" >
<tr>
<td>
<b><font size="4">Source</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SELECT ID="fulllist" NAME="source" SIZE="1" style="display:none">
<%while (!oRssource.eof) { %>
<OPTION ><% = oRssource(0) + " - " + oRssource(1) + " - " + oRssource(3) + " to " + oRssource(4) +";" + oRssource(2)%>
<% oRssource.MoveNext();
}
%>
</SELECT>
</td>
<td>

<INPUT TYPE="submit" VALUE="View">&nbsp; <!--(xxxTOTALS give values for the whole estate)-->
</td>
</tr>
</table>
<BR><BR>
<b><font size="4">Filters:</font></b>
<BR><BR>

<b>Domain</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SELECT ID="filterdomain" NAME="Domain" SIZE="1">
<OPTION> All
<% oRssource.close();
oCmd.CommandText = "select distinct domain from newmatrix order by 1";
oRssource =oCmd.Execute();
while (!oRssource.eof) {
%>
<OPTION> <% = oRssource(0) %>
<% oRssource.MoveNext(); }
%>
</SELECT>

<BR><BR>
<b>Trigram</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SELECT ID="filtertrigram" NAME="trigram" SIZE="1">
<OPTION> All
<% oRssource.close();
oCmd.CommandText = "select distinct substring(source,1,3) from newmatrix order by 1";
oRssource =oCmd.Execute();
while (!oRssource.eof) {
%>
<OPTION> <% = oRssource(0) %>
<% oRssource.MoveNext(); }
%>
</SELECT>

<BR><BR>
<b>Database</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SELECT ID="filterdatabase" NAME="database" SIZE="1">
<OPTION>All
<% oRssource.close();
oCmd.CommandText = "select distinct rtrim(substring(source,4,7)) from newmatrix order by 1";
oRssource =oCmd.Execute();
while (!oRssource.eof) {
%>
<OPTION> <% = oRssource(0) %>
<% oRssource.MoveNext(); }
%>
</SELECT>

&nbsp;&nbsp;&nbsp;&nbsp;(Selecting "TOTALS" displays stats for the whole estate, ignoring the trigram)

<BR><BR>
<b>Date Range</b>&nbsp;&nbsp; <SELECT ID="filterdaterange" NAME="daterange" SIZE="1">
<OPTION>All
<% oRssource.close();
oCmd.CommandText = "select distinct nm.daterangeindicator," +
"convert(varchar(30),dri.startdatetime,121)," +
"convert(varchar(30),dri.enddatetime,121)" +
" from newmatrix nm ,newmatrixdaterange dri" +
" where nm.daterangeindicator = dri.daterangeindicator" +
" order by 1 DESC,2 DESC";
oRssource =oCmd.Execute();
while (!oRssource.eof) {
%>
<OPTION> <% = oRssource(1) + " to " + oRssource(2) +";" + oRssource(0) %>
<% oRssource.MoveNext(); }
%>
</SELECT>



<BR><BR>
<INPUT TYPE="button" VALUE="Show Filtered List" onclick="populatefiltered();">
<!--<INPUT TYPE="button" VALUE="Show All" onclick="populateall();">-->

</FORM>



<%
oRssource.close();
%>
<!--#include file="closeconnection.asp"-->

</BODY>
</HTML>



[/CODE]