Solved

Passing Variables

Posted on 1997-11-11
6
173 Views
Last Modified: 2013-12-25
I have the following setup in an asp form:

<form action=nextframe.asp .......>
<input type=text name=userfield1>
<input type=text name=userfield2>

<input type=submit name="run nextframe.asp">
<input type=button name="run another win" onclick="parent.Display.location.href='anotherwin.asp?var1=userfield1&var2=userfield2'

I've tried several different iterations of the above (mixing in javascript/vbscript/asp) and nothing seems to work.  Thanks in advance for your help.

-Curt
0
Comment
Question by:v923146
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Holger101497
ID: 1855501
I don't have enough information to give a reliable answer, but I see two problems with your code that might cause your problem:

1] referencing. I assume that the frame you reference exists, but it should be at least "form.userfield1.value" to get the value of the textfields. (form elementes have a ".form" attribute that refers to the form that contains them)
2] You run into a problem as soon as one of the fields contains a space, because URLs cannot contains spaces. The answer here is to "escape" the value - that is standard URL-encoding, in fact the same one that the submit does when you click the button. It replaces all "illegal characters".
your onclick would have to look like this:
onclick="parent.Display.location.href='anotherwin.asp?var1='+escape(form.userfield1.value)+'&var2='+escape(form.userfield2.value)"
The escape translates the values to the same format as a submit would. If you try to evaluate the parameters in JavaScript, you can use unescape(value) to get the text that was originally typed in the textbox.

Let me know if this helped and don't accept somebody else's answer if it did.

Good luck!
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1855502
I don't have enough information to give a reliable answer, but I see two problems with your code that might cause your problem:

1] referencing. I assume that the frame you reference exists, but it should be at least "form.userfield1.value" to get the value of the textfields. (form elementes have a ".form" attribute that refers to the form that contains them)
2] You run into a problem as soon as one of the fields contains a space, because URLs cannot contains spaces. The answer here is to "escape" the value - that is standard URL-encoding, in fact the same one that the submit does when you click the button. It replaces all "illegal characters".
your onclick would have to look like this:
onclick="parent.Display.location.href='anotherwin.asp?var1='+escape(form.userfield1.value)+'&var2='+escape(form.userfield2.value)"
The escape translates the values to the same format as a submit would. If you try to evaluate the parameters in JavaScript, you can use unescape(value) to get the text that was originally typed in the textbox.

Let me know if this helped and don't accept somebody else's answer if it did.

Good luck!
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1855503
stupid server! Told me there was no response, but obviously it did at least listen, was just too busy to answer ;-)
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:v923146
ID: 1855504
Thanks Holger, your #2 did the trick.  Submit your comment as an answer so I can accept it.
0
 
LVL 6

Accepted Solution

by:
Holger101497 earned 200 total points
ID: 1855505
Glad to hear that it solved the problem!
I think #1 is a valid comment as well - which browser are you using? Netscape 4 and IE 4 are a LOT more generous when it comes to accessing variables. Try your code in NN3 or IE3, I don't think it'll work without the form.userfield1.value...

well... you can find everything Netscape has to say about escape/unescape at http://home.netscape.com/eng/mozilla/3.0/handbook/javascript/ref_d-e.htm#48073

I guess it's not much more helpful than what I told you, but just in case you care to read the official documentation ;-)

Good luck with your pages!
0
 

Author Comment

by:v923146
ID: 1855506
#1 is a valid comment - i was just lazy when typing out the example.

I am using IE 3.02 (or 4) as the preferred browser, but have been testing everything on netscape 4 as well.  Since those are the only browsers at my company, I'm not too concerned with the others :-)

Thanks again for your quick response.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now