View Full Version : Submit to a frame
landon11
08-28-2002, 07:46 PM
I posted this in General Web section but the frame I want to
submit to is an asp page getting the data with Request.Form("elename")
How do I submit a form to a particular frame of a page. If I have
Form.htm and in the action of the form I have Frames.htm, how
do I get the data in main frame of Frames.htm?
The form is on a seperate page. I want to do like this:
<form name="Form1" action="Frames.hmt" target="_blank">
but I want to the "Main" frame in the Frames.htm to recieve the
data.
glenngv
08-29-2002, 05:48 AM
if the name of the frame is "Main":
<form name="Form1" action="Frames.hmt" target="Main">
it's probably gonne be
<form name="Form1" action="Frames.asp" method="post" target="Main">
(submit to asp-page, with method post (if you wan't to use request.form ) )
landon11
08-29-2002, 03:00 PM
Thank you both.
landon11
08-30-2002, 08:26 PM
Originally posted by raf
it's probably gonne be
<form name="Form1" action="Frames.asp" method="post" target="Main">
(submit to asp-page, with method post (if you wan't to use request.form ) )
After testing this I cannot get it to work. I have tried this simple test :
Form.htm
<HTML>
<head>
</head>
<body>
<form name="Form1" action="frames.asp" method="post" target="main">
<input type=text name="text1"><br>
<input type=submit value="Submit">
</form>
</body>
</HTML>
frames.asp
<%@ language = vbscript %>
<HTML>
<FRAMESET rows="50%, 50%">
<Frame src="main.asp" name="main">
<FRAME SRC="bottom.asp" name="bottom">
</FRAMESET>
</HTML>
main.asp
<%@ language = vbscript %>
<html>
<head>
</head>
<BODY>
<%Response.Write("TextBox = " & Request.Form("text1"))%>
</body>
</html>
whammy
08-31-2002, 01:46 AM
I tried the same kind of test last night (practically identical) - which either proves we both have great troubleshooting skills or neither one of us know what we're doing with frames (the latter is probably true for me, at least, since I haven't used them in over a year - but I did reference some early sites I made with frames and javascript to double-check - and everything worked but trying to post to a frame.)
It didn't work for me either. But of course I've been looking at code all day, both days.
I'm thinking you shouldn't use frames, to be honest... they are way more trouble than they're worth, especially since you can build your pages dynamically using ASP.
I have never liked frames much anyway (in most cases)... but what you COULD do is submit your form to the SAME page - and depending on your validation on that page, display certain other pages in the frames (using javascript, of course, once the information was transmitted to the server, and back to the client!). That's the approach I would shoot for if I had to do it.
I hope that makes sense! :)
This post might help (if anyone has a solution, it may be john):
http://www.codingforums.com/showthread.php?s=&threadid=5240
But with all the problems you're running into with frames, take a little tip from me - avoid frames if at all possible (unless you've completely mastered them on your own beforehand and have a lot of time on your hands!).
Your life will be much less complicated without them (at least when it comes to trying to pass data between frames, be that client or server-side - although client-side isn't so bad).
P.S. ASP gives you all the tools you need to never have to use frames again (unless there's some weird absolute necessity for them, like a client that insists on them for no reason except they are trying to learn HTML).
That's my opinion, anyway. :D
glenngv
09-02-2002, 09:59 AM
you should have done this way to make it work:
Form.htm
<HTML>
<head>
</head>
<body>
<form name="Form1" action="frames.asp" method="post" target="main">
<input type=text name="text1"><br>
<input type=submit value="Submit">
</form>
</body>
</HTML>
frames.asp
<%@ language = vbscript %>
<HTML>
<FRAMESET rows="50%, 50%">
<Frame src="main.asp?text1=<%=request.form("text1")%>" name="main">
<FRAME SRC="bottom.asp" name="bottom">
</FRAMESET>
</HTML>
main.asp
<%@ language = vbscript %>
<html>
<head>
</head>
<BODY>
<%Response.Write("TextBox = " & Request.querystring("text1"))%>
</body>
</html>
if you don't want to pass data from frames.asp through URL (GET method), you can do it via javascript:
frames.asp
<%@ language = vbscript %>
<HTML>
<head>
<script language="javascript">
var text1 = "=<%=request.form("text1")%>";
</script>
</head>
<FRAMESET rows="50%, 50%">
<Frame src="main.asp" name="main">
<FRAME SRC="bottom.asp" name="bottom">
</FRAMESET>
</HTML>
main.asp
<%@ language = vbscript %>
<html>
<head>
</head>
<BODY>
<script language="javascript">
document.write(top.text1);
//or
//document.write(parent.text1);
</script>
</body>
</html>
so you have 3 page's : one frameset with two frames (main and bottom, and then you've got a page whitch is not part of the frameset (form) and that should load the results into one of the frames from frames.asp.
for starters : a frameset doesn't have an .asp axtension (it's a straight html file !)
second : a target (in the way you entered it) is only known to the frames in that frameset.
or like the manuals says : "If the current page is located in a frame set, use the Target text box to specify a target frame where the referenced page should appear."
the code i entered is used if you have a frame with for instance a form and an results frame in one frameset.
when you submit the form, the results or displayed in the results-frame (whitch was a 'blank' page before submitting)
third : whammy is right about the use of frames (at least for your problem). why use a frameset in this case?
if you really need it :
submit to an asp-page where you redirect to a frameset (if you must) and where you store (a part of) the data somewhere (in session-variables for instance) and then build up the pages from the frameset (using asp)
example : i once used a form that submitted to an asp-page whitch updated a record (customers info) in my DB and stored the customersID in a session-variable. it then redirected to a frameset where you had 2 pages (one containing the new info - selected from the DB using the customerID as criterium) and one containing the orders they placed (using same critirium). Because the customers info had to remain visible at all times (even if you had to scroll the orders) i used a frameset there.
glenngv
09-02-2002, 10:33 AM
Originally posted by raf
for starters : a frameset doesn't have an .asp axtension (it's a straight html file !)
i beg to disagree :eek:
what if there are dynamic data you want to output? like the src of a frame? or just anything similar to my previous post
sorry. didn't read it carefully enough + has been a wile i used it (in fact never used a frameset in an asp)
whammy
09-02-2002, 01:51 PM
)... but what you COULD do is submit your form to the SAME page - and depending on your validation on that page, display certain other pages in the frames
Looks like raf and I have about the same solution though. Submit the page to your frames.asp page, and do something like:
<%
E = Request.Form("someVar")
R = Request.Form("someotherVar")
%>
<frame src="<% = someVar %>" name="Main">
Where someVar is something like:
"main.asp?E=" & someotherVar & "&R=" & someotherVar
etc...
That IS one way to do it that would work fine...
glenngv
09-03-2002, 03:26 AM
Originally posted by whammy
Looks like raf and I have about the same solution though. Submit the page to your frames.asp page, and do something like:
<%
E = Request.Form("someVar")
R = Request.Form("someotherVar")
%>
<frame src="<% = someVar %>" name="Main">
Where someVar is something like:
"main.asp?E=" & someotherVar & "&R=" & someotherVar
etc...
That IS one way to do it that would work fine...
That was my suggestion on my 2nd post :D
landon11
09-03-2002, 05:59 PM
Thank you all for the information. The only reason I wanted to
use frames is b/c the asp page I am sending the info to is calling
a .dll that does some intense calculations. I wanted that page to
be in a frameset like <FRAMESET rows="100%, *%"> so that while
it is doing its work I can show a page that says Loading...
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.