Solved

Passing Variables

Posted on 1997-11-11
6
176 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

911 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