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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form data to one file in frames

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I'm sending an html form variable to an ASP generated Frames page. The menu to the left is HTML and the main window to the right is another form, which is ASP, and that is where I need the variable to show up. The frameset itself is within a simple ASP file. Try as I might, I can't seem to get the data input into the main window. Any ideas? Thanks!

Don [sig][/sig]
 
Try this...

default.html -
Code:
<html>
<body>
<form name=frmForm id=frmForm method=&quot;POST&quot; action=&quot;frameset.asp&quot;>
 Enter some text: <input type=text value=&quot;Submit this&quot; width=20 id=txtText name=txtText>
 <br><input type=submit value=&quot;Submit&quot;>
</form>
</html>

frameset.asp -
Code:
<%
  Session(&quot;txtText&quot;) = Request.Form(&quot;txtText&quot;)
%>
<html>
<frameset cols=&quot;*,*&quot;>
  <frame src=&quot;left.html&quot; name=&quot;leftframe&quot;>
  <frame src=&quot;right.asp&quot; name=&quot;rightframe&quot;>
</frameset>
</html>

left.html -
Code:
<html>
<body>
 <b>Menu</b>
</body>
</html>

right.asp -
Code:
<html>
<body>
You submitted: <b><%=Session(&quot;txtText&quot;)%></b>
</body>
</html>

Yeah I know of the evils of session variables but sometimes they come in handy. This is one of those times. There is probably another way to do it but this is by far the easiest.

Good luck,
Rob [sig][/sig]
 
Thanks Rob!

I think it's very close now, though I wasn't sure what to do with the session so now I get a type mismatch on it. Here's what I have in the html form (actually two separate forms on the same page - these will eventually be coming in from another site but we will tell them what to use in the form tags):

<center><form name=&quot;kiosk&quot; method=&quot;post&quot; action=&quot;../cgi-bin/frames.asp&quot; id=&quot;kiosk&quot;>
<input type=image SRC=&quot;../images/health_temp.gif&quot; BORDER=0>
<input type=hidden name=&quot;kiosk&quot; value=&quot;KIOSK_HEALTH&quot; id=&quot;kiosk&quot;>
</form>

<center><form name=&quot;kiosk&quot; method=&quot;post&quot; action=&quot;../cgi-bin/frames.asp&quot; id=&quot;kiosk&quot;>
<input type=image SRC=&quot;../images/other_temp.gif&quot; BORDER=0>
<input type=hidden name=&quot;kiosk&quot; value=&quot;KIOSK_OTHER&quot; id=&quot;kiosk&quot;>
</form></center>

Then in the next form I have:

<%
Session(&quot;kiosk&quot;) = Request.Form(&quot;kiosk&quot;)
%>

<frameset COLS=&quot;125,100%&quot; BORDER=0 frameborder=&quot;0&quot;>
<frame src=&quot;../html/menu.html&quot; name=&quot;menu&quot; NORESIZE SCROLLING=&quot;NO&quot; MARGINHEIGHT=1 MARGINWIDTH=1 TITLE=&quot;menu&quot;>
<frame src=&quot;regional.asp&quot; name=&quot;body&quot; NORESIZE SCROLLING=&quot;AUTO&quot; TITLE=&quot;body&quot;>
</frameset>

Then in the next form I have:

<%=Session(&quot;kiosk&quot;) %>

It is this last bit that apparently fails. There is already an if else subroutine that was taking the value from the frame before it was a frame, but I am not sure how to apply the session to it. I need something like,

if Session(&quot;kiosk&quot;) = &quot;SEARCH_HEALTH&quot; then
formname = &quot;search_health.asp&quot;
else formname = &quot;search_other.asp&quot;
end if

Before I can get that far, there is a type mismatch 'Session'

Don [sig][/sig]
 
Don,

I believe the code is getting confused. You can't have non-unique form names and input names. Try this instead...

default.html -
Code:
<center>
<form name=&quot;frmKioskH&quot; id=&quot;frmKioskH&quot; method=&quot;post&quot; action=&quot;frameset.asp&quot;>
 <input type=hidden name=&quot;kioskH&quot; id=&quot;kioskH&quot; value=&quot;KIOSK_HEALTH&quot;>
 <input type=submit value=&quot;Search Health&quot;>
</form>

<form name=&quot;frmKioskO&quot; id=&quot;frmKioskO&quot; method=&quot;post&quot; action=&quot;frameset.asp&quot;>
 <input type=hidden name=&quot;kioskO&quot; id=&quot;kioskO&quot; value=&quot;KIOSK_OTHER&quot;>
 <input type=submit value=&quot;Search Other&quot;>
</form>
</center>

frameset.asp -
Code:
<%
  Session(&quot;kioskH&quot;) = Request.Form(&quot;kioskH&quot;)
  Session(&quot;kioskO&quot;) = Request.Form(&quot;kioskO&quot;)
%>

<html>
<frameset cols=&quot;*,*&quot;>
  <frame src=&quot;left.html&quot; name=&quot;leftframe&quot;>
  <frame src=&quot;right.asp&quot; name=&quot;rightframe&quot;>
</frameset>
</html>

left.html -
Code:
<html>
<body>
 <b>Menu</b>
</body>
</html>

right.asp -
Code:
<%
kioskH=Session(&quot;kioskH&quot;)
kioskO=Session(&quot;kioskO&quot;)

if kioskH <> &quot;&quot; then
 formname = &quot;search_health.asp&quot;
elseif kioskO <> &quot;&quot; then
 formname = &quot;search_other.asp&quot;
else
 formname = &quot; - Oops, go back and select something.&quot;
end if
%>

<html>
<body>
You selected to search <%=formname%>
</body>
</html>

Later,
Rob [sig][/sig]
 
Thanks Rob!

I'm not in the office today but will try it on Monday.

Don [sig][/sig]
 
For some reason, the formname value is still coming up empty after trying to pass it to the search page. I've gone through everything to be sure I didn't miss something obvious in your posting, but I don't see anything wrong. It appears to simply be getting lost on the frames page or the page is not pulling up the session for some reason. The fact that it is not &quot;elsing&quot; to search_other.asp seems to indicate that it is not getting either variable at all. I am using an image to submit the form, though I don't think that could have anything to do with it. There are no error messages either.

Thanks in advance for any other help you may be able to give and for what you have given already!

Don [sig][/sig]
 
Oops! I'm not sure why, but it seems to be working all of a sudden! Maybe in spite of several reloads, the html file remained cached. I reloaded it again and it worked! Thanks a bundle Rob! %-) [sig][/sig]
 
Now that everything is working perfectly, here's a monkey wrench in the works: how can I translate the form into a plain hyperlink? I've done it before but there appear to be two tags with the name &quot;id&quot; so I am not sure how to do it here. Here is what I've tried so far (the form is working, but the hyperlink is not):

The original form with session info:

[tt]<form name=&quot;frmKioskH&quot; method=&quot;post&quot; action=&quot;cgi-bin/frames.asp&quot; id=&quot;frmKioskH&quot;>
<input type=image SRC=&quot;images/health_temp.gif&quot; BORDER=0>
<input type=hidden name=&quot;kioskH&quot; id=&quot;kioskH&quot; value=&quot;KIOSK_HEALTH&quot;>
</form>[/tt]

My text hyperlink:

[tt]<a href=&quot;cgi-bin/frames.asp?id=frmKioskH&kioskH=KIOSK_HEALTH&quot;>Health-Related Issues</a>[/tt]

Thanks!

Don [sig][/sig]
 
Don,

I'm not quite sure what you mean by &quot;two tags with the name
'id'&quot; but the answer to your question is use the GET method rather than the POST method in your form. Also, if you are trying to use an image as a submit button then you will need to include an onClick event ( onClick=&quot;form.submit()&quot; ) in the input tag.

You may want to consider using POST as that keeps all the stuff off the URL line (and there is a limit to the number of characters).

Later, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Hi Rob,

I think you misunderstood. The form is working fine so it doesn't need to be changed at all but I am trying to come up with a non-form hyperlink to do the same job. In the form tag itself, there is an id=&quot;frmKioskH&quot; while in one of the hidden tags, there is one that says, id=&quot;kioskH&quot; In other words, both form lines have something called &quot;id.&quot;

The point of this is, I want to try to do the same thing that the form is already doing (and doing well) as a regular hyperlink rather than a form and passing the values that way similar to the example I posted. The reason is that the input is to be coming from another site not related, but contracted with us and they are having some &quot;issues&quot; using a form. The form I created was just for testing purposed to try to emulate their site and to get the rest of the VBscript coding done.

Thanks!
Don [sig][/sig]
 
Ooohhhh...

id= is the 'same' as name=. it is just the, well, 'id' of the tag. This is used by DHTML, javascript, and the DOM to distinguish individual tags. To answer your question (correctly this time ;-) ) build the hyperlink as such...

Code:
<a href=&quot;cgi-bin/frames.asp?variable1=value1&variable2=value2&variable3=value3...&quot;>Health-Related Issues</a>

the variable is not necessarily the id/name of an input tag. the variable will be used by your frames.asp page as such...

Code:
<%
 variable1=QueryString(&quot;variable1&quot;)
 variable2=QueryString(&quot;variable2&quot;)
 variable3=QueryString(&quot;variable3&quot;)
 ...etc...
%>

You don't have to use the same variable names on both the url line and the asp code but it makes it easier to read (unless the url variable name is something like 'kH')

So, to solve your particular problem here is the <a> tag...
Code:
<a href=&quot;cgi-bin/frames.asp?kioskH=KIOSK_HEALTH&quot;>Health-Related Issues</a>

Notice that any reference to the form is removed. It isn't necessary. Here is the asp...

Code:
<%
 Dim kioskH
 kioskH = UCASE(QueryString(&quot;kioskH&quot;)) 'the ucase just helps to insure that a match will be made

 if kioskH = &quot;KIOSK_HEALTH&quot; then
   'do something
 elseif kioskH = &quot;KIOSK_WHATEVER&quot; then
   'do something else
 else
   'no match
 end if
%>

Later,
[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Rob,

Thanks! I tried it but the hyperlink doesn't work with the existing VBScript. If you look several postings above, you will see the code that is working, which is creating the session needed to load the variables into one frame of a frames site.

For reference, here are the two forms that I am trying to convert into hyperlinks (these are working very well):


[tt]<center><form name=&quot;frmKioskH&quot; method=&quot;post&quot; action=&quot;cgi-bin/frames.asp&quot; id=&quot;frmKioskH&quot;>
<input type=image SRC=&quot;images/health_temp.gif&quot; BORDER=0>
<input type=hidden name=&quot;kioskH&quot; id=&quot;kioskH&quot; value=&quot;KIOSK_HEALTH&quot;>
</form>

<center><form name=&quot;frmKioskO&quot; method=&quot;post&quot; action=&quot;cgi-bin/frames.asp&quot; id=&quot;frmKioskO&quot;>
<input type=image SRC=&quot;images/other_temp.gif&quot; BORDER=0>
<input type=hidden name=&quot;kioskO&quot; id=&quot;kioskO&quot; value=&quot;KIOSK_OTHER&quot;>
</form></center>[/tt]

and here are the session lines in the frames ASP page (this is also working well):

[tt]<%
Session(&quot;kioskH&quot;) = Request.Form(&quot;kioskH&quot;)
Session(&quot;kioskO&quot;) = Request.Form(&quot;kioskO&quot;)
%>[/tt]

and here are the lines in the next frame where the information is used (this is working well too):

[tt]<%
kioskH=Session(&quot;kioskH&quot;)
kioskO=Session(&quot;kioskO&quot;)
if kioskH <> &quot;&quot; then
FormName = &quot;search_health.asp&quot;
elseif kioskO <> &quot;&quot; then
FormName = &quot;search.asp&quot;
end if

if kioskH <> &quot;&quot; then
SearchType = &quot;Search for Health Related Issues&quot;
else
SearchType = &quot;Search for non-Health Related Issues&quot;
end if
%>[/tt]

I thought it would be possible to simply convert the two forms to plain hyperlinks without rewriting the rest but if it is not, I will tell the other site that will be creating the link that they will need to find a way to deal with a form!

Don
[sig][/sig]
 
Don,
There isn't that much to rewrite. Simply substitute QueryString for Response.Form and it will work fine. That said, here is some slightly modified code (for efficiency and ease of reading). It only uses a single variable called kiosk.

Code:
Other site...
<a href=&quot;cgi-bin/frames.asp?kiosk=KIOSK_HEALTH&quot;>Health-Related Issues</a>
<a href=&quot;cgi-bin/frames.asp?kiosk=KIOSK_OTHER&quot;>Health-Related Issues</a>

Your frames.asp page...
<%
Session(&quot;kiosk&quot;) = UCASE(QueryString(&quot;kiosk&quot;))
%>

Your search page...
<%
Dim kiosk
kiosk=Session(&quot;kiosk&quot;)

if kiosk = &quot;KIOSK_HEALTH&quot; then
 FormName = &quot;search_health.asp&quot;
 SearchType = &quot;Search for Health Related Issues&quot;
elseif kiosk = &quot;KIOSK_OTHER&quot; then
 FormName = &quot;search.asp&quot;
 SearchType = &quot;Search for non-Health Related Issues&quot;
elseif kiosk = &quot;&quot; then
 (either)
 FormName = &quot;search.asp&quot;
 SearchType = &quot;Search for non-Health Related Issues&quot;
 (or)
 FormName = &quot;error.asp&quot;
 SearchType = &quot;&quot;
end if
%>

Later,
[sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Hi Rob,

Thanks a lot! I'll try it when I'm back in the office on Monday. I'm out of town now.

Don [sig][/sig]
 
Hi Rob,

The code looks good and makes sense even to me though I am getting a &quot;Type mismatch: 'QueryString'&quot; error on this line in frames.asp:

Session(&quot;kiosk&quot;) = UCASE(QueryString(&quot;kiosk&quot;))

I don't yet see anything wrong but I am still looking.

Don [sig][/sig]
 
Use this instead:

Session(&quot;kiosk&quot;) = UCASE(Request.QueryString(&quot;kiosk&quot;))

[sig]<p>Choo Khor<br><a href=mailto:choo.khor@intelebill.com>choo.khor@intelebill.com</a><br>[/sig]
 
Yes, that was it exactly! I decided to leave in the error lines, though there is not yet an error.asp file. Hopefully one won't be needed but I'll create it anyway &quot;just in case!&quot;

Thanks again to everyone who helped!

Don [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top