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!

Form post with out a server; client side only

Status
Not open for further replies.

TerryDad2

Programmer
Jul 10, 2002
29
US
I am trying to set up a series of forms that will create a query to a msaccess database located on a cd. I want to have forms that post to another page on the cd. The posting goes well, but on the next page, none of my attempts to get the posted data work. I have used request.form and get a object required error. I have also tried putting the data into the url and using request.querystring and get the same error.

I know that using asp would be better and easier, but that is not an option since I need to have the entire application portable on the cd.

How do I use forms that are only client side and get the posted data on the next page?

Terry
 
The two approaches that occur to me right off hand are:[ul]
[li]Have the form pages write the data to a TEMP directory file, then redirect to display pages which pull the data back from the file. This means using the FileSystemObject or some other technique, such as the ADO recordset's Open and Save methods against a text file.[/li]
[li]Use HTML frames to do the job. The idea here is to have a frame that stays loaded and holds data that the pages loaded into the second frame can reference. So a forms page stores stuff in the "global data" frame, and a work and display page pulls the form parameters from those variables in the "global" frame's page. This works best for me with iframes but that's just the way I like to do it - problem is the user must have IE. If you're using VBScript though we've already made that assumption, right?[/li][/ul]
There just isn't a Request object in client-side script, that's an ASP object.

The only other thing that comes to mind having written all that is running a tiny web server off the CD, one that supports CGI or maybe even a limited ASP or PHP subset. That's probably overkill though. ;-) Funny thing is I recently found a WSH-based web server written in VBScript!!! No, it doesn't support ASP or CGI, but it might not take much.
 
Oops! Reading the stuff I wrote above I think an example of the iframe approach might clarify things a little. This is short, maybe not sweet, but it'll give you something to look over and play with.

Copy/paste/save these 3 files with NotePad into a folder. Then double-click on
Code:
main.htm
and follow the bouncing ball:

Code:
main.htm
Code:
<HTML>
<HEAD>
<TITLE>Self-posting Craziness</TITLE>
<SCRIPT language=&quot;vbscript&quot;>
Dim strMyNameIs
Sub LoadFrame(strURL)
  document.all.fraCanvas.src = strURL
End Sub
</SCRIPT>
</HEAD>
<BODY>
<IFRAME id=&quot;fraCanvas&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot;
  width=&quot;100%&quot; height=&quot;100%&quot; src=&quot;form.htm&quot;>
</BODY>
</HTML>
Code:
form.htm
Code:
<HTML>
<HEAD>
<SCRIPT language=&quot;vbscript&quot;>
Sub btnSubmit_onclick
  parent.strMyNameIs = frmGetName.txtName.value
  parent.LoadFrame(&quot;display.htm&quot;)
End Sub
</SCRIPT>
</HEAD>
<BODY>
<FORM id=&quot;frmGetName&quot;>
  What's your name? <INPUT id=&quot;txtName&quot; type=&quot;text&quot; size=&quot;20&quot;>
  <INPUT id=&quot;btnSubmit&quot; type=&quot;button&quot; value=&quot;Submit&quot;>
</FORM>
</BODY>
</HTML>
Code:
display.htm
Code:
<HTML>
<HEAD>
<SCRIPT language=&quot;vbscript&quot;>
Sub window_onload
  spnName.innerText = parent.strMyNameIs
End Sub
Sub btnPlayAgain_onclick
  parent.LoadFrame(&quot;form.htm&quot;)
End Sub
</SCRIPT>
</HEAD>
<BODY>
  Your name is, your name is, your name is <FONT color=&quot;red&quot;>*scratches*</FONT>
  <SPAN id=&quot;spnName&quot;></SPAN><BR><BR><BR><BR>
  <INPUT id=&quot;btnPlayAgain&quot; type=&quot;button&quot; value=&quot;Play Again&quot;>
</BODY>
</HTML>
I hope this helps illustrate what I tried so poorly to explain above.

In some ways this is way more powerful than ASP. You can even cache ADO objects simply by creating them in the
Code:
main
page. What it does is free you from the tyranny of stateless web programming. You can maintain all the state you want in the &quot;global&quot; (
Code:
main
) data items and objects.

To avoid running into browser security headaches try naming your main page
Code:
main
Code:
.hta
. This gives you an HTML Application, and you can even do some slick stuff via the <HTA:APPLICATION> element that now becomes active. It gives you an extended object model and even more control than IE normally offers.
 
Thanks. I had tried the forms before, but had trouble with my script not recognizing the &quot;parent&quot;. It seems my error was not defining each variable in the parent before using it. JS lets you create the variables without defining them

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top