Chomauk
Programmer
- Jun 8, 2001
- 130
I am attempting to create my first web site and I am becoming overwhelmed with ASP, VBScript, JavaScript, DHTML. I have been making great progress, however, I am at a point where I need to get some expert advice/suggestions.
First of all when would I want to run server side scripts and when would I want to run Client scripts.
Below is the current asp page I have created which works fine, however, where the <script language=vbscript> is located I can only use this as client(correct?). Is this the way it must be? I also have code to run on the server using <% %> but this doesn't work where I have <script Language = vbscript>. I tried <@% Language = VBScript %> but it doesn't work either and I don't get an error.
I also have a connection to my SQL Database and return a recordset successfully when running from the server. I have included a comment and a question in my code in UPPER CASE between the <script language=vbscript> and </script> tags. Any help/advice would be greatly appreciated.
I am running IIS using Windows 98.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<html>
<style TYPE="text/css">
<!--
TABLE {
FONT-WEIGHT: normal;
FONT-SIZE: 24px;
COLOR: blue;
LINE-HEIGHT: 120%;
FONT-FAMILY: Verdana,Arial,sans-serif;
TEXT-DECORATION: none
}
.PickLeague{CURSOR:hand}
-->
</style>
<head>
<SCRIPT language=VBScript>
'THIS ONLY WORKS AS A CLIENT SCRIPT.
sub selectLeague_OnClick()
With document.LeagueList.selectLeague
.disabled = true
Dim intCount
With document.all.SelectTeam.Options
for intCount = 0 to .length
.Remove(intCount) ' REMOVE CURRENT LIST
Next
End With
' I'LL WANT TO CONNECT TO THE DATABASE AGAIN AND RETURN A RECORDSET TO LOAD INTO THE SELECT BOX.
' THE BELOW CODE (LOCATED BETWEEN <% AND %>) TO CONNECT TO SQL DOES NOT WORK HERE. WHY IS THAT?
' HOW COULD I MAKE IT SO I DON'T HAVE TO REUSE THE SAME CODE IN THE SAME PAGE? THE BELOW CODE WAS WRITTEN TO VERIFY THAT I COULD RECIEVE THE SELECTED TEXT OF THE FIRST SELECT BOX.
Dim oOption
set oOption = document.createElement("OPTION"
oOption.text=.Options(.selectedIndex).Text
document.all.SelectTeam.add(oOption)
set oOption = Nothing
.disabled = false
End With
end sub
</SCRIPT>
</head>
<body style="color:blue" bgcolor="Gainsboro">
<p>
<pre>
<font size="5" face="Times, serif" color="green">
Welcome to Dawg Pounders Fantasy Football Draft Site...
</font>
<font size="3" face="Times, serif" color="purple">
Still under construction but making great progress!!!
</font>
<%
Response.Write "<form name='LeagueList'>"
dim rs
dim strConn
set rs=server.CreateObject("adodb.recordset"
rs.CursorLocation=3 'clientside
rs.CursorType=3 'staticrecordset
rs.PageSize=100
strConn="Provider=SQLOLEDB;Persist Security Info=False;" & _
"User ID=sa;Initial Catalog=FantasyFootball2001;" & _
"Initial File Name=C:\MSSQL7\Data\FantasyFootball2001_Data.MDF"
rs.Open "GetLeagueNames",strConn
rs.movefirst
Response.Write "<table>"
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "<fieldset style='width: 180'>"
Response.Write "<Legend style='font-size:12pt'> Select league </Legend>"
'Response.Write "<font size='2' face='Times, serif'>"
'Response.Write "Select League Name"
'Response.Write "</font>"
Response.Write "<select style='width: 175; font-size:16pt' Name='selectLeague' size='10'"
Response.Write "<option> </option>"
Do While Not rs.EOF
Response.Write "<option>" & rs("League" & "</option>"
rs.MoveNext
Loop
rs.Close
Set rs =nothing
Response.Write "</select>"
Response.Write "</fieldset"
Response.Write "</td>"
Response.Write "<td width='50'>"
Response.Write "</td>"
Response.Write "<td>"
Response.Write "<fieldset style='width: 180'>"
Response.Write "<Legend style='font-size:12pt'> Select Team </Legend>"
Response.Write "<select id='idSelectTeam' style='width: 175; font-size:12pt' Name='selectTeam' size='10'"
Response.Write "<option> </option>"
Response.Write "</select>"
Response.Write "</fieldset"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "</form>"
%>
<A style="color:red" HREF="News.asp">Main Test Page</A>
<A style="color:red" HREF="Login.asp">Login Test Page</A>
</body>
</html>
First of all when would I want to run server side scripts and when would I want to run Client scripts.
Below is the current asp page I have created which works fine, however, where the <script language=vbscript> is located I can only use this as client(correct?). Is this the way it must be? I also have code to run on the server using <% %> but this doesn't work where I have <script Language = vbscript>. I tried <@% Language = VBScript %> but it doesn't work either and I don't get an error.
I also have a connection to my SQL Database and return a recordset successfully when running from the server. I have included a comment and a question in my code in UPPER CASE between the <script language=vbscript> and </script> tags. Any help/advice would be greatly appreciated.
I am running IIS using Windows 98.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<html>
<style TYPE="text/css">
<!--
TABLE {
FONT-WEIGHT: normal;
FONT-SIZE: 24px;
COLOR: blue;
LINE-HEIGHT: 120%;
FONT-FAMILY: Verdana,Arial,sans-serif;
TEXT-DECORATION: none
}
.PickLeague{CURSOR:hand}
-->
</style>
<head>
<SCRIPT language=VBScript>
'THIS ONLY WORKS AS A CLIENT SCRIPT.
sub selectLeague_OnClick()
With document.LeagueList.selectLeague
.disabled = true
Dim intCount
With document.all.SelectTeam.Options
for intCount = 0 to .length
.Remove(intCount) ' REMOVE CURRENT LIST
Next
End With
' I'LL WANT TO CONNECT TO THE DATABASE AGAIN AND RETURN A RECORDSET TO LOAD INTO THE SELECT BOX.
' THE BELOW CODE (LOCATED BETWEEN <% AND %>) TO CONNECT TO SQL DOES NOT WORK HERE. WHY IS THAT?
' HOW COULD I MAKE IT SO I DON'T HAVE TO REUSE THE SAME CODE IN THE SAME PAGE? THE BELOW CODE WAS WRITTEN TO VERIFY THAT I COULD RECIEVE THE SELECTED TEXT OF THE FIRST SELECT BOX.
Dim oOption
set oOption = document.createElement("OPTION"
oOption.text=.Options(.selectedIndex).Text
document.all.SelectTeam.add(oOption)
set oOption = Nothing
.disabled = false
End With
end sub
</SCRIPT>
</head>
<body style="color:blue" bgcolor="Gainsboro">
<p>
<pre>
<font size="5" face="Times, serif" color="green">
Welcome to Dawg Pounders Fantasy Football Draft Site...
</font>
<font size="3" face="Times, serif" color="purple">
Still under construction but making great progress!!!
</font>
<%
Response.Write "<form name='LeagueList'>"
dim rs
dim strConn
set rs=server.CreateObject("adodb.recordset"
rs.CursorLocation=3 'clientside
rs.CursorType=3 'staticrecordset
rs.PageSize=100
strConn="Provider=SQLOLEDB;Persist Security Info=False;" & _
"User ID=sa;Initial Catalog=FantasyFootball2001;" & _
"Initial File Name=C:\MSSQL7\Data\FantasyFootball2001_Data.MDF"
rs.Open "GetLeagueNames",strConn
rs.movefirst
Response.Write "<table>"
Response.Write "<tr>"
Response.Write "<td>"
Response.Write "<fieldset style='width: 180'>"
Response.Write "<Legend style='font-size:12pt'> Select league </Legend>"
'Response.Write "<font size='2' face='Times, serif'>"
'Response.Write "Select League Name"
'Response.Write "</font>"
Response.Write "<select style='width: 175; font-size:16pt' Name='selectLeague' size='10'"
Response.Write "<option> </option>"
Do While Not rs.EOF
Response.Write "<option>" & rs("League" & "</option>"
rs.MoveNext
Loop
rs.Close
Set rs =nothing
Response.Write "</select>"
Response.Write "</fieldset"
Response.Write "</td>"
Response.Write "<td width='50'>"
Response.Write "</td>"
Response.Write "<td>"
Response.Write "<fieldset style='width: 180'>"
Response.Write "<Legend style='font-size:12pt'> Select Team </Legend>"
Response.Write "<select id='idSelectTeam' style='width: 175; font-size:12pt' Name='selectTeam' size='10'"
Response.Write "<option> </option>"
Response.Write "</select>"
Response.Write "</fieldset"
Response.Write "</td>"
Response.Write "</tr>"
Response.Write "</table>"
Response.Write "</form>"
%>
<A style="color:red" HREF="News.asp">Main Test Page</A>
<A style="color:red" HREF="Login.asp">Login Test Page</A>
</body>
</html>