Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Staying on the same page for Everything???

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
Maybe I am asking too much. I have a sample of my code. I want to be able to add a record in the form portion and then have the Table portion update to show the new record.
Maybe someone could see whats up.
It's running the Add and Delete sub's before the buttons are clicked. And if it inserts a record the values are blank.

--------------------
<html>
<%@ Language=VBScript%>
<head>
<title>New Patient</title>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Add_OnClick
Dim TheForm
Set TheForm = Document.ValidForm
If (TheForm.T1.Value) <> &quot;&quot; Then
<%' open SQL server database %>
<%Set Conn = server.CreateObject(&quot;ADODB.Connection&quot;)%>
<%Conn.Open &quot;driver={SQL Server};server=myserver.com;uid=ID;pwd=pass;database=Universal1;&quot;%>
<%Conn.Execute(&quot;INSERT INTO [syspat] (PFName,PLName) VALUES ('&quot; &amp; T1 &amp; &quot;','&quot; &amp; T2 &amp; &quot;')&quot;)%>
MsgBox &quot;Thank you.&quot;
End If
End Sub

Sub Delete_OnClick
<%Conn.Execute(&quot;DELETE FROM [syspat] WHERE PFName = ''&quot;)%>
End sub
-->
</SCRIPT>
</head>

<body>
<table border=&quot;1&quot; width=&quot;99%&quot; height=&quot;80&quot;>
<tr>
<td width=&quot;35%&quot; height=&quot;74&quot;>
<form name=&quot;ValidForm&quot;>
<p align=&quot;center&quot;>Add New Patients</p>
<p>Fname<input type=&quot;text&quot; name=&quot;T1&quot; size=&quot;20&quot;><br>
Lname <input type=&quot;text&quot; name=&quot;T2&quot; size=&quot;20&quot;><br>
Address <input type=&quot;text&quot; name=&quot;T3&quot; size=&quot;20&quot;><br>
Address2 <input type=&quot;text&quot; name=&quot;T4&quot; size=&quot;20&quot;><br>
City <input type=&quot;text&quot; name=&quot;T5&quot; size=&quot;20&quot;><br>
State <input type=&quot;text&quot; name=&quot;T6&quot; size=&quot;5&quot;><br>
Zip <input type=&quot;text&quot; name=&quot;T7&quot; size=&quot;14&quot;><br>
Country<input type=&quot;text&quot; name=&quot;T8&quot; size=&quot;14&quot;></p>
<p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;AddNew&quot; name=&quot;Add&quot;>
<input type=&quot;reset&quot; value=&quot;Clear&quot; name=&quot;Clear&quot;>
<input type=&quot;submit&quot; value=&quot;Delete Blanks Records&quot; name=&quot;Delete&quot;>

</form>
------------------------

TIA
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
The way you do it now is impossible: somehow there has to be some traffic between client and server, and you can't put DB interaction inside clientside VBscript, so that won't work :).
If I have a good understanding of what your problem, you want to add and delete records from your database, and stay on the same page right?
In my humple ;-) opinion, there's two good ways to do this:

1. Use a hidden frame where you do all the processing:
Create a two-frame page, 1 of only 1 pixel height (name it &quot;process&quot;), and that covers the rest of the screen (name it &quot;display&quot;).
Put all the DB interaction code in the &quot;process&quot; frame, and the code for the form in &quot;display&quot;.
Change your form tag to the following:

<form name=&quot;ValidForm&quot; action=&quot;process.asp&quot; method=&quot;post&quot; target=&quot;process&quot;>

Whenever one of the buttons is clicked now, the values from the form will be sent to the hidden frame, where the processing is done. The &quot;display&quot; frame stays on the same page (it shows the form).

2. Use WDDX to convert the recordset object to Javascript so you can do everything on the client. There is an excellent tutorial on this on webmonkey:

I hope you can figure it out, post again if you get stuck! :)

<webguru>iqof188</webguru>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top