Solved

Passing Variables

Posted on 1997-11-11
6
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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