Ask a Question related to ASP Database, Design and Development.
-
Jeremy #1
New Function gives Object Expected Error
Hello,
This problem has been driving me nuts... I have a set of functions
and code which work fine by itself and another function which works
fine by itself, but when I join them into one form, they give an
'object expected error at the <BODY onLoad="initControls()> line. Any
ideas? Thanks in advance! Here is my code:
<%@ language = "JavaScript" %>
<%
var strDept = "";
var strCourse = "";
if (Request.querystring("stateChanged") == "true")
{
strDept = Request.Form("cboDept");
strCourse = Request.Form("cboCourse");
}
var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:/Inetpub/wwwroot/ITI/fpdb/Resume04.mdb";
%>
<script language=JavaScript>
function initControls()
{
populateDept();
populateCourse();
populateSect();
}
function populateDept()
{
<%
var rs = Server.CreateObject("ADODB.Recordset");
var sql = "select distinct Dept from Courses order by Dept"
rs.Open(sql,strconnection);
var n=1;
while (!rs.EOF)
{
var dpt = rs.Fields("Dept");
Response.Write("document.repForm.cboDept[" + n + "] = new Option('"
+ dpt + "');");
if (new String(strDept).search(dpt) != -1)
Response.Write("document.repForm.cboDept[" + n + "].selected =
true;");
rs.MoveNext();
n++;
}
rs.Close();
%>
}
function populateCourse()
{
<%
if (strDept != "")
{
var rs2 = Server.CreateObject("ADODB.Recordset");
var strSql = "select distinct Course from Courses where Dept = '" +
strDept + "' ";
rs2.Open(strSql,strconnection);
var n=1;
while (!rs2.EOF)
{
var crs = rs2.Fields("Course");
Response.Write("document.repForm.cboCourse[" + n + "] = new
Option('" + crs + "');");
if (new String(strCourse).search(crs) != -1)
Response.Write("document.repForm.cboCourse[" + n + "].selected =
true;");
rs2.MoveNext();
n++;
}
rs2.Close();
}
%>
}
function fillCourse()
{
document.repForm.action = "test.asp?stateChanged=true";
document.repForm.submit();
}
function populateSect()
{
<%
if (strCourse != "")
{
var rs3 = Server.CreateObject("ADODB.Recordset");
var strSql = "select distinct Sect from Courses where Course = '" +
strCourse + "' ";
rs3.Open(strSql,strconnection);
var n=1;
while (!rs3.EOF)
{
var sct = rs3.Fields("Sect");
Response.Write("document.repForm.cboSect[" + n + "] = new Option('"
+ sct + "');");
rs3.MoveNext();
n++;
}
rs3.Close();
}
%>
}
function populateJob()
{
<%
var tbl="";
var rs4 = Server.CreateObject("ADODB.Recordset");
var sql = "select distinct Preference from Preferences";
rs4.Open(sql,strconnection);
var n=0;
while (!rs4.EOF)
{
var pref = rs4.Fields("Preference");
{
var tbl = tbl + "<table border='0'>\n";
{
tbl += " <td>\n";
tbl += " <input type='text' size=65 name='txt" + n + "'
value='" + pref + "'>\n";
tbl += " </td>\n";
for (var j=0; j<5; j++)
{
tbl += " <td>\n";
tbl += " <input type='radio' name='box" + n + "'
value='Box" + n + "'>\n";
tbl += " </td>\n";
}
}
tbl += "</table>\n";
}
rs4.MoveNext();
n++;
}
Response.Write("document.repForm.write('" + tbl + "')");
rs4.Close();
%>
}
</script>
<html>
<BODY onLoad="initControls()">
<FORM action="html/browse_product.asp" method="post" name="repForm"
onSubmit="return Validate(this);">
<%=tbl%>
<select name="cboDept" onChange="fillCourse()">
<option value="Select Dept" selected> Select Dept
</option>
</select>
<select name="cboCourse" onChange="fillCourse()">
<option value="Select Course" selected> Select
Course
</option>
</select>
<select name="cboSect">
<option value="Select Section" selected> Select
Section
</option>
</select>
</FORM>
</BODY>
</HTML>
Jeremy Guest
-
object expected error - audioLoadingStart( )
Trying to play a swf in a web page using flash. It plays fine, but throws an IE error. The error is: "A runtime error has occurred. Do you... -
error in havoc-car, object expected
Trying to build a nice little race game and the graphics are commin along very well, the problem is, im a 3dmodeller not a scripter, but with the... -
Error object expected
hey folks! I'm getting the usual NOOB error object expected. I'm creating a simple box and applying a texture to it: The specific line i get the... -
object expected error
Hi I am having several problems that might be a bug or bad codeing but I cant tell as the error only happens immediatly after I save my working... -
IIS ASP Object Expected Error
John wrote: Should be "Err.Clear". The Number propery is read-only IIRC. -
Roland Hall #2
Re: New Function gives Object Expected Error
"Jeremy" wrote:'
: This problem has been driving me nuts... I have a set of functions
: and code which work fine by itself and another function which works
: fine by itself, but when I join them into one form, they give an
: 'object expected error at the <BODY onLoad="initControls()> line. Any
: ideas? Thanks in advance! Here is my code:
<!--SNiP-->
Where does populateJob() get called?
--
Roland
This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
[url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]
-Technet Script Center-
[url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]
-MSDN Library-
[url]http://msdn.microsoft.com/library/default.asp[/url]
Roland Hall Guest
-
Harag #3
Re: New Function gives Object Expected Error
try putting your <script></script> code in the right place - maybe
that will help. it should be between the <head> tags.
<html>
<title>
Your page title
</title>
<head>
<script language="javascript">
</script>
</head>
<body>
</body>
</html>
HTH
Al.
On 7 Jan 2004 21:38:08 -0800, [email]jeremy_zifchock@yahoo.com[/email] (Jeremy)
wrote:
>Hello,
>
>This problem has been driving me nuts... I have a set of functions
>and code which work fine by itself and another function which works
>fine by itself, but when I join them into one form, they give an
>'object expected error at the <BODY onLoad="initControls()> line. Any
>ideas? Thanks in advance! Here is my code:
>
><%@ language = "JavaScript" %>
><%
>
>var strDept = "";
>var strCourse = "";
>if (Request.querystring("stateChanged") == "true")
> {
> strDept = Request.Form("cboDept");
> strCourse = Request.Form("cboCourse");
> }
>var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>Source=C:/Inetpub/wwwroot/ITI/fpdb/Resume04.mdb";
>%>><script language=JavaScript>>function initControls()
> {
> populateDept();
> populateCourse();
> populateSect();
> }
>
>function populateDept()
> {
> <%
> var rs = Server.CreateObject("ADODB.Recordset");
> var sql = "select distinct Dept from Courses order by Dept"
> rs.Open(sql,strconnection);
> var n=1;
> while (!rs.EOF)
> {
> var dpt = rs.Fields("Dept");
> Response.Write("document.repForm.cboDept[" + n + "] = new Option('"
>+ dpt + "');");
>
> if (new String(strDept).search(dpt) != -1)>
> Response.Write("document.repForm.cboDept[" + n + "].selected =
>true;");> rs.MoveNext();
> n++;
> }
> rs.Close();
> %>
> }
>
>function populateCourse()
> {
> <%
> if (strDept != "")
> {
> var rs2 = Server.CreateObject("ADODB.Recordset");
> var strSql = "select distinct Course from Courses where Dept = '" +
>strDept + "' ";
> rs2.Open(strSql,strconnection);
> var n=1;
> while (!rs2.EOF)
> {
> var crs = rs2.Fields("Course");
> Response.Write("document.repForm.cboCourse[" + n + "] = new
>Option('" + crs + "');");
>
> if (new String(strCourse).search(crs) != -1)
>
> Response.Write("document.repForm.cboCourse[" + n + "].selected =
>true;");
> rs2.MoveNext();
> n++;
> }
> rs2.Close();
> }
> %>
> }
>
>function fillCourse()
> {
> document.repForm.action = "test.asp?stateChanged=true";
> document.repForm.submit();
> }
>
>function populateSect()
> {
> <%
> if (strCourse != "")
> {
> var rs3 = Server.CreateObject("ADODB.Recordset");
> var strSql = "select distinct Sect from Courses where Course = '" +
>strCourse + "' ";
> rs3.Open(strSql,strconnection);
> var n=1;
> while (!rs3.EOF)
> {
> var sct = rs3.Fields("Sect");
> Response.Write("document.repForm.cboSect[" + n + "] = new Option('"
>+ sct + "');");
> rs3.MoveNext();
> n++;
> }
> rs3.Close();
> }
> %>
> }
>
>function populateJob()
> {
> <%
> var tbl="";
> var rs4 = Server.CreateObject("ADODB.Recordset");
> var sql = "select distinct Preference from Preferences";
> rs4.Open(sql,strconnection);
> var n=0;
> while (!rs4.EOF)
> {
> var pref = rs4.Fields("Preference");
> {
> var tbl = tbl + "<table border='0'>\n";
> {
>
> tbl += " <td>\n";
> tbl += " <input type='text' size=65 name='txt" + n + "'
>value='" + pref + "'>\n";
> tbl += " </td>\n";
>
> for (var j=0; j<5; j++)
> {
> tbl += " <td>\n";
> tbl += " <input type='radio' name='box" + n + "'
>value='Box" + n + "'>\n";
> tbl += " </td>\n";
> }
> }
> tbl += "</table>\n";
> }
> rs4.MoveNext();
> n++;
> }
> Response.Write("document.repForm.write('" + tbl + "')");
> rs4.Close();
> %>
> }
>
></script>
>
><html>
>
><BODY onLoad="initControls()">
>
> <FORM action="html/browse_product.asp" method="post" name="repForm"
>onSubmit="return Validate(this);">
>
><%=tbl%>
> <select name="cboDept" onChange="fillCourse()">
> <option value="Select Dept" selected> Select Dept
> </option>
> </select>
>
> <select name="cboCourse" onChange="fillCourse()">
> <option value="Select Course" selected> Select
>Course
> </option>
> </select>
>
> <select name="cboSect">
> <option value="Select Section" selected> Select
>Section
> </option>
> </select>
>
>
></FORM>
>
></BODY>
></HTML>Harag Guest
-
Martin Honnen #4
Re: New Function gives Object Expected Error
Jeremy wrote:
If you get an error with body onload you have an error in your client> This problem has been driving me nuts... I have a set of functions
> and code which work fine by itself and another function which works
> fine by itself, but when I join them into one form, they give an
> 'object expected error at the <BODY onLoad="initControls()> line. Any
> ideas? Thanks in advance! Here is my code:
side script. Simply examine the output of your ASP page, if you need
help with that try a group on client side scripting.
--
Martin Honnen
[url]http://JavaScript.FAQTs.com/[/url]
Martin Honnen Guest
-
Bob Lehmann #5
Re: New Function gives Object Expected Error
You are mixing client and server side script - no can do....
function populateDept()
{
<%
var rs = Server.CreateObject("ADODB.Recordset");
var sql = "select distinct Dept from Courses order by Dept"
rs.Open(sql,strconnection);
var n=1;
while (!rs.EOF)
{
etc. etc...
}
Bob Lehmann
"Jeremy" <jeremy_zifchock@yahoo.com> wrote in message
news:f9d85033.0401072138.324e75fa@posting.google.c om...> Hello,
>
> This problem has been driving me nuts... I have a set of functions
> and code which work fine by itself and another function which works
> fine by itself, but when I join them into one form, they give an
> 'object expected error at the <BODY onLoad="initControls()> line. Any
> ideas? Thanks in advance! Here is my code:
>
> <%@ language = "JavaScript" %>
> <%
>
> var strDept = "";
> var strCourse = "";
> if (Request.querystring("stateChanged") == "true")
> {
> strDept = Request.Form("cboDept");
> strCourse = Request.Form("cboCourse");
> }
> var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=C:/Inetpub/wwwroot/ITI/fpdb/Resume04.mdb";
> %>
> <script language=JavaScript>
>
> function initControls()
> {
> populateDept();
> populateCourse();
> populateSect();
> }
>
> function populateDept()
> {
> <%
> var rs = Server.CreateObject("ADODB.Recordset");
> var sql = "select distinct Dept from Courses order by Dept"
> rs.Open(sql,strconnection);
> var n=1;
> while (!rs.EOF)
> {
> var dpt = rs.Fields("Dept");
> Response.Write("document.repForm.cboDept[" + n + "] = new Option('"
> + dpt + "');");
>
> if (new String(strDept).search(dpt) != -1)
>
> Response.Write("document.repForm.cboDept[" + n + "].selected =
> true;");
> rs.MoveNext();
> n++;
> }
> rs.Close();
> %>
> }
>
> function populateCourse()
> {
> <%
> if (strDept != "")
> {
> var rs2 = Server.CreateObject("ADODB.Recordset");
> var strSql = "select distinct Course from Courses where Dept = '" +
> strDept + "' ";
> rs2.Open(strSql,strconnection);
> var n=1;
> while (!rs2.EOF)
> {
> var crs = rs2.Fields("Course");
> Response.Write("document.repForm.cboCourse[" + n + "] = new
> Option('" + crs + "');");
>
> if (new String(strCourse).search(crs) != -1)
>
> Response.Write("document.repForm.cboCourse[" + n + "].selected =
> true;");
> rs2.MoveNext();
> n++;
> }
> rs2.Close();
> }
> %>
> }
>
> function fillCourse()
> {
> document.repForm.action = "test.asp?stateChanged=true";
> document.repForm.submit();
> }
>
> function populateSect()
> {
> <%
> if (strCourse != "")
> {
> var rs3 = Server.CreateObject("ADODB.Recordset");
> var strSql = "select distinct Sect from Courses where Course = '" +
> strCourse + "' ";
> rs3.Open(strSql,strconnection);
> var n=1;
> while (!rs3.EOF)
> {
> var sct = rs3.Fields("Sect");
> Response.Write("document.repForm.cboSect[" + n + "] = new Option('"
> + sct + "');");
> rs3.MoveNext();
> n++;
> }
> rs3.Close();
> }
> %>
> }
>
> function populateJob()
> {
> <%
> var tbl="";
> var rs4 = Server.CreateObject("ADODB.Recordset");
> var sql = "select distinct Preference from Preferences";
> rs4.Open(sql,strconnection);
> var n=0;
> while (!rs4.EOF)
> {
> var pref = rs4.Fields("Preference");
> {
> var tbl = tbl + "<table border='0'>\n";
> {
>
> tbl += " <td>\n";
> tbl += " <input type='text' size=65 name='txt" + n + "'
> value='" + pref + "'>\n";
> tbl += " </td>\n";
>
> for (var j=0; j<5; j++)
> {
> tbl += " <td>\n";
> tbl += " <input type='radio' name='box" + n + "'
> value='Box" + n + "'>\n";
> tbl += " </td>\n";
> }
> }
> tbl += "</table>\n";
> }
> rs4.MoveNext();
> n++;
> }
> Response.Write("document.repForm.write('" + tbl + "')");
> rs4.Close();
> %>
> }
>
> </script>
>
> <html>
>
> <BODY onLoad="initControls()">
>
> <FORM action="html/browse_product.asp" method="post" name="repForm"
> onSubmit="return Validate(this);">
>
> <%=tbl%>
> <select name="cboDept" onChange="fillCourse()">
> <option value="Select Dept" selected> Select Dept
> </option>
> </select>
>
> <select name="cboCourse" onChange="fillCourse()">
> <option value="Select Course" selected> Select
> Course
> </option>
> </select>
>
> <select name="cboSect">
> <option value="Select Section" selected> Select
> Section
> </option>
> </select>
>
>
> </FORM>
>
> </BODY>
> </HTML>
Bob Lehmann Guest
-
Jeremy #6
Re: New Function gives Object Expected Error
Nope that doesn't do it. The thing that gets me is if I take out
either the initControls() function, or the populateJob() function, the
script works, but when I try to join the two it doesn't...
Harag <harag@REMOVETHESECAPITALSsofthome.net> wrote in message news:<mcgqvvsnu82ej5i0c1g5ojufktr14koriu@4ax.com>. ..> try putting your <script></script> code in the right place - maybe
> that will help. it should be between the <head> tags.
>
> <html>
> <title>
> Your page title
> </title>
> <head>
>
> <script language="javascript">
> </script>
>
> </head>
> <body>
> </body>
> </html>
>
>
> HTH
> Al.
>
>
>
> On 7 Jan 2004 21:38:08 -0800, [email]jeremy_zifchock@yahoo.com[/email] (Jeremy)
> wrote:
>>> >Hello,
> >
> >This problem has been driving me nuts... I have a set of functions
> >and code which work fine by itself and another function which works
> >fine by itself, but when I join them into one form, they give an
> >'object expected error at the <BODY onLoad="initControls()> line. Any
> >ideas? Thanks in advance! Here is my code:
> >
> ><%@ language = "JavaScript" %>
> ><%
> >
> >var strDept = "";
> >var strCourse = "";
> >if (Request.querystring("stateChanged") == "true")
> > {
> > strDept = Request.Form("cboDept");
> > strCourse = Request.Form("cboCourse");
> > }
> >var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> >Source=C:/Inetpub/wwwroot/ITI/fpdb/Resume04.mdb";
> >%>>> ><script language=JavaScript>>> >function initControls()
> > {
> > populateDept();
> > populateCourse();
> > populateSect();
> > }
> >
> >function populateDept()
> > {
> > <%
> > var rs = Server.CreateObject("ADODB.Recordset");
> > var sql = "select distinct Dept from Courses order by Dept"
> > rs.Open(sql,strconnection);
> > var n=1;
> > while (!rs.EOF)
> > {
> > var dpt = rs.Fields("Dept");
> > Response.Write("document.repForm.cboDept[" + n + "] = new Option('"
> >+ dpt + "');");
> >
> > if (new String(strDept).search(dpt) != -1)>> >
> > Response.Write("document.repForm.cboDept[" + n + "].selected =
> >true;");> rs2.Close();> > rs.MoveNext();
> > n++;
> > }
> > rs.Close();
> > %>
> > }
> >
> >function populateCourse()
> > {
> > <%
> > if (strDept != "")
> > {
> > var rs2 = Server.CreateObject("ADODB.Recordset");
> > var strSql = "select distinct Course from Courses where Dept = '" +
> >strDept + "' ";
> > rs2.Open(strSql,strconnection);
> > var n=1;
> > while (!rs2.EOF)
> > {
> > var crs = rs2.Fields("Course");
> > Response.Write("document.repForm.cboCourse[" + n + "] = new
> >Option('" + crs + "');");
> >
> > if (new String(strCourse).search(crs) != -1)
> >
> > Response.Write("document.repForm.cboCourse[" + n + "].selected =
> >true;");
> > rs2.MoveNext();
> > n++;
> > }> %>> > }> rs3.Close();> > }
> >
> >function fillCourse()
> > {
> > document.repForm.action = "test.asp?stateChanged=true";
> > document.repForm.submit();
> > }
> >
> >function populateSect()
> > {
> > <%
> > if (strCourse != "")
> > {
> > var rs3 = Server.CreateObject("ADODB.Recordset");
> > var strSql = "select distinct Sect from Courses where Course = '" +
> >strCourse + "' ";
> > rs3.Open(strSql,strconnection);
> > var n=1;
> > while (!rs3.EOF)
> > {
> > var sct = rs3.Fields("Sect");
> > Response.Write("document.repForm.cboSect[" + n + "] = new Option('"
> >+ sct + "');");
> > rs3.MoveNext();
> > n++;
> > }> %>> > }> > }
> >
> >function populateJob()
> > {
> > <%
> > var tbl="";
> > var rs4 = Server.CreateObject("ADODB.Recordset");
> > var sql = "select distinct Preference from Preferences";
> > rs4.Open(sql,strconnection);
> > var n=0;
> > while (!rs4.EOF)
> > {
> > var pref = rs4.Fields("Preference");
> > {
> > var tbl = tbl + "<table border='0'>\n";
> > {
> >
> > tbl += " <td>\n";
> > tbl += " <input type='text' size=65 name='txt" + n + "'
> >value='" + pref + "'>\n";
> > tbl += " </td>\n";
> >
> > for (var j=0; j<5; j++)
> > {
> > tbl += " <td>\n";
> > tbl += " <input type='radio' name='box" + n + "'
> >value='Box" + n + "'>\n";
> > tbl += " </td>\n";
> > }
> > }
> > tbl += "</table>\n";
> > }
> > rs4.MoveNext();
> > n++;
> > }
> > Response.Write("document.repForm.write('" + tbl + "')");
> > rs4.Close();
> > %>
> > }
> >
> ></script>
> >
> ><html>
> >
> ><BODY onLoad="initControls()">
> >
> > <FORM action="html/browse_product.asp" method="post" name="repForm"
> >onSubmit="return Validate(this);">
> >
> ><%=tbl%>
> > <select name="cboDept" onChange="fillCourse()">
> > <option value="Select Dept" selected> Select Dept
> > </option>
> > </select>
> >
> > <select name="cboCourse" onChange="fillCourse()">
> > <option value="Select Course" selected> Select
> >Course
> > </option>
> > </select>
> >
> > <select name="cboSect">
> > <option value="Select Section" selected> Select
> >Section
> > </option>
> > </select>
> >
> >
> ></FORM>
> >
> ></BODY>
> ></HTML>Jeremy Guest
-
Harag #7
Re: New Function gives Object Expected Error
as Roland said:
Where does populateJob() get called?
Have you looked at the client side code that the serverside creates ?
take off the "onload" in the body tag then check the client code.
HTH
AL
On 8 Jan 2004 09:44:12 -0800, [email]jeremy_zifchock@yahoo.com[/email] (Jeremy)
wrote:
>Nope that doesn't do it. The thing that gets me is if I take out
>either the initControls() function, or the populateJob() function, the
>script works, but when I try to join the two it doesn't...
>
>Harag <harag@REMOVETHESECAPITALSsofthome.net> wrote in message news:<mcgqvvsnu82ej5i0c1g5ojufktr14koriu@4ax.com>. ..>> try putting your <script></script> code in the right place - maybe
>> that will help. it should be between the <head> tags.
>>
>> <html>
>> <title>
>> Your page title
>> </title>
>> <head>
>>
>> <script language="javascript">
>> </script>
>>
>> </head>
>> <body>
>> </body>
>> </html>
>>
>>
>> HTH
>> Al.
>>
>>
>>
>> On 7 Jan 2004 21:38:08 -0800, [email]jeremy_zifchock@yahoo.com[/email] (Jeremy)
>> wrote:
>>>>>> >Hello,
>> >
>> >This problem has been driving me nuts... I have a set of functions
>> >and code which work fine by itself and another function which works
>> >fine by itself, but when I join them into one form, they give an
>> >'object expected error at the <BODY onLoad="initControls()> line. Any
>> >ideas? Thanks in advance! Here is my code:
>> >
>> ><%@ language = "JavaScript" %>
>> ><%
>> >
>> >var strDept = "";
>> >var strCourse = "";
>> >if (Request.querystring("stateChanged") == "true")
>> > {
>> > strDept = Request.Form("cboDept");
>> > strCourse = Request.Form("cboCourse");
>> > }
>> >var strconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>> >Source=C:/Inetpub/wwwroot/ITI/fpdb/Resume04.mdb";
>> >%>>>>> ><script language=JavaScript>>>>> >function initControls()
>> > {
>> > populateDept();
>> > populateCourse();
>> > populateSect();
>> > }
>> >
>> >function populateDept()
>> > {
>> > <%
>> > var rs = Server.CreateObject("ADODB.Recordset");
>> > var sql = "select distinct Dept from Courses order by Dept"
>> > rs.Open(sql,strconnection);
>> > var n=1;
>> > while (!rs.EOF)
>> > {
>> > var dpt = rs.Fields("Dept");
>> > Response.Write("document.repForm.cboDept[" + n + "] = new Option('"
>> >+ dpt + "');");
>> >
>> > if (new String(strDept).search(dpt) != -1)>>>> >
>> > Response.Write("document.repForm.cboDept[" + n + "].selected =
>> >true;");>> rs2.Close();>> > rs.MoveNext();
>> > n++;
>> > }
>> > rs.Close();
>> > %>
>> > }
>> >
>> >function populateCourse()
>> > {
>> > <%
>> > if (strDept != "")
>> > {
>> > var rs2 = Server.CreateObject("ADODB.Recordset");
>> > var strSql = "select distinct Course from Courses where Dept = '" +
>> >strDept + "' ";
>> > rs2.Open(strSql,strconnection);
>> > var n=1;
>> > while (!rs2.EOF)
>> > {
>> > var crs = rs2.Fields("Course");
>> > Response.Write("document.repForm.cboCourse[" + n + "] = new
>> >Option('" + crs + "');");
>> >
>> > if (new String(strCourse).search(crs) != -1)
>> >
>> > Response.Write("document.repForm.cboCourse[" + n + "].selected =
>> >true;");
>> > rs2.MoveNext();
>> > n++;
>> > }>> %>>> > }>> rs3.Close();>> > }
>> >
>> >function fillCourse()
>> > {
>> > document.repForm.action = "test.asp?stateChanged=true";
>> > document.repForm.submit();
>> > }
>> >
>> >function populateSect()
>> > {
>> > <%
>> > if (strCourse != "")
>> > {
>> > var rs3 = Server.CreateObject("ADODB.Recordset");
>> > var strSql = "select distinct Sect from Courses where Course = '" +
>> >strCourse + "' ";
>> > rs3.Open(strSql,strconnection);
>> > var n=1;
>> > while (!rs3.EOF)
>> > {
>> > var sct = rs3.Fields("Sect");
>> > Response.Write("document.repForm.cboSect[" + n + "] = new Option('"
>> >+ sct + "');");
>> > rs3.MoveNext();
>> > n++;
>> > }>> %>>> > }>> > }
>> >
>> >function populateJob()
>> > {
>> > <%
>> > var tbl="";
>> > var rs4 = Server.CreateObject("ADODB.Recordset");
>> > var sql = "select distinct Preference from Preferences";
>> > rs4.Open(sql,strconnection);
>> > var n=0;
>> > while (!rs4.EOF)
>> > {
>> > var pref = rs4.Fields("Preference");
>> > {
>> > var tbl = tbl + "<table border='0'>\n";
>> > {
>> >
>> > tbl += " <td>\n";
>> > tbl += " <input type='text' size=65 name='txt" + n + "'
>> >value='" + pref + "'>\n";
>> > tbl += " </td>\n";
>> >
>> > for (var j=0; j<5; j++)
>> > {
>> > tbl += " <td>\n";
>> > tbl += " <input type='radio' name='box" + n + "'
>> >value='Box" + n + "'>\n";
>> > tbl += " </td>\n";
>> > }
>> > }
>> > tbl += "</table>\n";
>> > }
>> > rs4.MoveNext();
>> > n++;
>> > }
>> > Response.Write("document.repForm.write('" + tbl + "')");
>> > rs4.Close();
>> > %>
>> > }
>> >
>> ></script>
>> >
>> ><html>
>> >
>> ><BODY onLoad="initControls()">
>> >
>> > <FORM action="html/browse_product.asp" method="post" name="repForm"
>> >onSubmit="return Validate(this);">
>> >
>> ><%=tbl%>
>> > <select name="cboDept" onChange="fillCourse()">
>> > <option value="Select Dept" selected> Select Dept
>> > </option>
>> > </select>
>> >
>> > <select name="cboCourse" onChange="fillCourse()">
>> > <option value="Select Course" selected> Select
>> >Course
>> > </option>
>> > </select>
>> >
>> > <select name="cboSect">
>> > <option value="Select Section" selected> Select
>> >Section
>> > </option>
>> > </select>
>> >
>> >
>> ></FORM>
>> >
>> ></BODY>
>> ></HTML>Harag Guest
-
Roland Hall #8
Re: New Function gives Object Expected Error
"Bob Lehmann" wrote:
: You are mixing client and server side script - no can do....
:
: function populateDept()
: {
: <%
: var rs = Server.CreateObject("ADODB.Recordset");
: var sql = "select distinct Dept from Courses order by Dept"
: rs.Open(sql,strconnection);
: var n=1;
: while (!rs.EOF)
: {
: etc. etc...
: }
:
:
: Bob Lehmann
Bob...
That was my first thought too but it appears since he is using javascript
for server-side and client-side and it appears the server-side, even in the
middle of client side, writes part of the client side code. When the client
gets it, it should be correct. Granted he should move his server-side code
out for performance reasons but I didn't notice any technical issues.
--
Roland
This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
[url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]
-Technet Script Center-
[url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]
-MSDN Library-
[url]http://msdn.microsoft.com/library/default.asp[/url]
Roland Hall Guest
-
Mark Schupp #9
Re: New Function gives Object Expected Error
He really needs to post what he gets from "view source".
--
Mark Schupp
Head of Development
Integrity eLearning
[url]www.ielearning.com[/url]
"Roland Hall" <nobody@nowhere> wrote in message
news:%23cZS9Cp1DHA.832@TK2MSFTNGP09.phx.gbl...the> "Bob Lehmann" wrote:
> : You are mixing client and server side script - no can do....
> :
> : function populateDept()
> : {
> : <%
> : var rs = Server.CreateObject("ADODB.Recordset");
> : var sql = "select distinct Dept from Courses order by Dept"
> : rs.Open(sql,strconnection);
> : var n=1;
> : while (!rs.EOF)
> : {
> : etc. etc...
> : }
> :
> :
> : Bob Lehmann
>
> Bob...
>
> That was my first thought too but it appears since he is using javascript
> for server-side and client-side and it appears the server-side, even inclient> middle of client side, writes part of the client side code. When thecode> gets it, it should be correct. Granted he should move his server-side[url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]> out for performance reasons but I didn't notice any technical issues.
>
> --
> Roland
>
> This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose.
> -Technet Knowledge Base-
>[url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]> -Technet Script Center-
>> -MSDN Library-
> [url]http://msdn.microsoft.com/library/default.asp[/url]
>
>
>
Mark Schupp Guest
-
Jeremy #10
Re: New Function gives Object Expected Error
Thanks for your input... It all seems to work independently, which is
why I'm confused. I'm pretty new to asp programming. How might you
suggest that I move my code server side, while still being able to
update the dropdowns dynamically?
Jeremy
"Roland Hall" <nobody@nowhere> wrote in message news:<#cZS9Cp1DHA.832@TK2MSFTNGP09.phx.gbl>...> "Bob Lehmann" wrote:
> : You are mixing client and server side script - no can do....
> :
> : function populateDept()
> : {
> : <%
> : var rs = Server.CreateObject("ADODB.Recordset");
> : var sql = "select distinct Dept from Courses order by Dept"
> : rs.Open(sql,strconnection);
> : var n=1;
> : while (!rs.EOF)
> : {
> : etc. etc...
> : }
> :
> :
> : Bob Lehmann
>
> Bob...
>
> That was my first thought too but it appears since he is using javascript
> for server-side and client-side and it appears the server-side, even in the
> middle of client side, writes part of the client side code. When the client
> gets it, it should be correct. Granted he should move his server-side code
> out for performance reasons but I didn't notice any technical issues.
>
> --
> Roland
>
> This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose.
> -Technet Knowledge Base-
> [url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]
> -Technet Script Center-
> [url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]
> -MSDN Library-
> [url]http://msdn.microsoft.com/library/default.asp[/url]Jeremy Guest
-
Roland Hall #11
Re: New Function gives Object Expected Error
"Mark Schupp" wrote:
: He really needs to post what he gets from "view source".
Agreed. We also already know he appears to not be calling one function.
--
Roland
This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
[url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]
-Technet Script Center-
[url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]
-MSDN Library-
[url]http://msdn.microsoft.com/library/default.asp[/url]
Roland Hall Guest
-
Roland Hall #12
Re: New Function gives Object Expected Error
"Jeremy" wrote:
: Thanks for your input...
You're welcome. Just calling it as I see it.
: It all seems to work independently, which is
: why I'm confused.
That's fine but what you showed us is not complete. There is no call shown
to one of the functions. That might be a factor.
: I'm pretty new to asp programming. How might you
: suggest that I move my code server side, while still being able to
: update the dropdowns dynamically?
ASP processing takes place before the client (browser) gets the results. If
user interaction is required, then a trip back to the server if you want to
do more server-side. You can modify drop-down lists dynamically on the
client side but not if you require more data from the server. To do that
you will have to make a connection to either a file or database, depending
on where your data is coming from and then popuplate the fields in your code
so when it is passed to the client, it will display the results.
IMHO, it is a better design, especially for performance, to grab the data at
the last possible moment, and then close the connection to the database.
Process the data server-side and deliver to the client. You could put the
options into an array, or multiple arrays and then use client-side scripting
if you need to make dynamic changes to the lists.
What would be a cause to modify away from this approach? You may have a lot
of data or data gets updated and you constantly need to get a fresh look at
it. And I'm sure there are other reasons but if you only need to get it
once, then consider dynamically updating the lists client-side.
Here is an example, although he decided to change his design, that shows
that you can dynamically change one list from another client-side. It's not
a great example because I think the code can be modified to reduce the size
but it is a perfect example to show you client-side dynamic list updating is
possible.
[url]http://kiddanger.com/lab/dtwilliams/selects.html[/url]
--
Roland
This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
[url]http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0[/url]
-Technet Script Center-
[url]http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp[/url]
-MSDN Library-
[url]http://msdn.microsoft.com/library/default.asp[/url]
Roland Hall Guest



Reply With Quote

