|
Posted by sumGirl on October 18, 2004, 1:00 pm
Please log in for more thread options
Okay, I know nothing and I admit it. I have a simple form with a set
of buttons at the top and depending on the button you push, displays
some data at the button of the form. This is probably to much info,
but the sub actually gets the data from a SQL server and then
dynamically builds the table to display at the bottom of the page.
I would like to divide this single page into two pages so that I can
have all the buttons in one frame and the results in another
frame...how do I do this? Heres an example of my html (just one button
shown here):
<html>
<head>
<body>
<Script Language="VBScript">
Sub btnListBackups_OnClick()
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=SQLOLEDB" & _
";Data Source=" & "DBDELTA1" & _
";Integrated Security=SSPI"
Set recordSet = oConnection.Execute("EXEC tempdb..sp_lastback")
myResultTable = "<table border=""1"">"
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<th>" & _
recordSet.Fields(i).Name & _
"</th>"
Next
myResultTable = myResultTable & "</tr>"
Do While Not recordSet.EOF
myResultTable = myResultTable & "<tr>"
For i = 0 To recordSet.Fields.Count - 1
myResultTable = myResultTable & _
"<td>" & _
recordSet.Fields(i).Value & _
"</td>"
Next
myResultTable = myResultTable & "</tr>"
recordSet.MoveNext
Loop
myResultTable = myResultTable & "</table>"
recordSet.Close
oConnection.Close
Results.innerHTML = myResultTable
End Sub
</script>
<input type="button" id="btnListBackups" value="List Backups">
<hr>
<nobr Id=Results></nobr>
</body>
</html>
|
|
Posted by Andy Dingley on October 19, 2004, 1:18 am
Please log in for more thread options
On 18 Oct 2004 12:00:42 -0700, emebohw@netscape.net (sumGirl) wrote:
>Okay, I know nothing and I admit it.
Here's one fact - go off and have a play with it, see where you get
to.
"Scripting" comes in two flavours, server-side and client-side.
Server-side scripting runs on the server. Code runs, the page gets
sent. Then it stops running - it can't change the page or respond to
anything that happens from users clicking on it. Running on the
server is a good place to connect to databases.
Client-side scripting runs on the web browser. It's good at responding
to user clicks, poor at generating pages and pretty much impossible to
connect to databases from.
So your example needs to run on the server. By the looks of the
example you've pretty much coded this, and you've coded it in ASP
(which might even work). Then you've wrapped it in <script> rather <%
.... %> so that it's seen as client-side code. It's good code, but in
the wrong place.
Change it to be server-side code. Use the <%...%> syntax. Using
"runat='server'" is often confusing (although it would work).
Suggestion: Ditch VBScript - JScript is a much better language.
Now you have one problem left, how to do the "two views". Forget this
for the moment, get it working first with just one.
Then write it so that a different result is returned depending on the
URL supplied - look at how to read parameters from the query string.
Give it sensible default action if the parameter is missing.
To permit switching between the two views, then it's impractical to do
this client-side. Instead resubmit the page request and generate it
again. Place the button(s) on the page inside a form, coded so that
it's submitted as a GET (not a POST) and the parameters are supplied
appropriately (Using GET instead of POST makes both of the display
options bookmarkable).
--
Smert' spamionam
|
| Similar Threads | Posted | | Today is your day, your mountain is waiting, so get on your way. | February 20, 2008, 7:32 am |
| newbie frame question | December 19, 2004, 9:58 pm |
| Link in a one frame change content of another frame. | October 7, 2005, 1:30 pm |
| Simply log-in panel | July 12, 2006, 5:16 am |
| Fractions Simply Won't Display Properly | June 29, 2005, 10:06 am |
| Changing 2 frames in one click | November 16, 2004, 7:15 am |
| Box appearing when I click on graphics in IE 6.0 | November 10, 2005, 11:55 am |
| Looking for invisible click-counter | March 16, 2006, 2:10 pm |
| Submit button and click vs. enter | July 30, 2004, 5:33 pm |
| CSS: Change text color upon click | July 31, 2005, 12:53 pm |
|