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

Posting form data to a pop up window

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I have been all over the net and trying code. So far nothing has worked.

I'm running IE6 whith this code:

formtest1.asp's code is:

<form action=&quot;formtest2.asp&quot; method=&quot;post&quot; target=&quot;foo&quot; onsubmit=&quot;window.open('', 'foo', 'width=400,height=300,status=yes,resizable=yes,scrollbars=yes')&quot;>
<p>Some text here:
<input name=&quot;sometext&quot; type=&quot;text&quot; id=&quot;sometext&quot;>
</p>
<p>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Submit&quot;>
</p>
</form>


What I want to do is submit a form's data to a popup window that will create a report. You can not use the open command or the posted info will not transfer.

formtest2.asp's code is:

<p>Submitted form window...</p>
Value of sometext was <%=Request.Form(&quot;sometext&quot;)%>

I get the small popup window *blank*, and another fullsize window which is formtest2.asp.

Please tell me what I am doing wrong?
 
Use 'escape' to pass the values just the same as you would a cgi script:

here's a code snippet that will get you on your way...

'fname=' + escape(document.frm.fname.value) + '&' +
'lname=' + escape(document.frm.lname.value) + '&' +
'address=' + escape(document.frm.address.value) + '&' +
'city=' + escape(document.frm.city.value) + '&' +
'st=' + escape(document.frm.st.value) + '&' +
'zip=' + escape(document.frm.zip.value) + '&' +
'areacode=' + escape(document.frm.areacode.value) + '&' +
'phone=' + escape(document.frm.phone.value) + '&' +
'email=' + escape(document.frm.email.value) + '&' +
'qty=' + escape(document.frm.qty.value) + '&' +
'subttl=' + escape(document.frm.subttl.value) + '&' +
'grandttl=' +escape(document.frm.grandttl.value)

There's always a better way...
 
Two alternatives:

You can make a function to construct a URL like this :

function submitForm(form) {
var myURL = 'formtest2.asp?sometext=' + escape(form.sometext.value) + &quot;&sometext2=&quot; + ....etc
return myURL;
}

and make the change to form to

onSubmit=&quot;window.open(submitForm(this),'foo','width.....')&quot;>

You needs to follow pattern URL?<NAME1>=<VALUE1>&<NAME2>=<NAME2>&.......
Also the VALUEs have to be escaped to change spaces etc into an internet safe string.

Alternatively why not just add the code for resizing etc into formtest2.asp and remove the onsubmit code.

Hope this makes sence.

Kev
[afro2]
 
I searched the net yesterday most of the day, and found you can not remove the toolbars, etc. from a window once it is up.
There are 2 ways to do this:
With the onLoad command from the second window, I can move and resize the form, but can not remove the toolbars. :(

Or use a get, and not a post in the form as JS will not pass the values from 1 window to a new window.

This means if I try to do a Request.Form(&quot;sometext&quot;) from the popup, it will not get anything. I guess I'll have to change the form to pass everything thru the URL, and not with a post.
If anyone has a better solution, leave it here, but I'm finding none.

Thanks all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top