Solved

Passing Variables

Posted on 1997-11-11
6
182 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

820 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