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

Posting form to a popup 1

Status
Not open for further replies.

xscape

Programmer
Apr 18, 2001
144
GB
Hi,

I'm trying to figure out a way of posting a form to a popup. It's just a poll form that posts to an ASP page, but I'd like the page to open in a popup. Here's a cut down version of the form I want to post:

<form name=&quot;poll_form&quot; method=&quot;post&quot; action=&quot;poll.asp?poll_id=1&quot;>
Q. What do you think of JavaScript!?
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;1&quot;>Excellent<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;2&quot;>Very Good<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;3&quot;>Average<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;4&quot;>Poor<br>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Vote!&quot;>
</form>

Any ideas? I'm sure it's possible - but for various reasons I'd rather avoid having to insert code into the <head> section of my page. Thanks a lot!

Cheers
Rob
 
<form ... target=&quot;_blank&quot;> ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
Hi, thanks for replying neversleep. I only wanted a small popup - not a full blown window. If that's the only way of doing it then I'll go with that. Any other suggestions?

Cheers Neversleep!

Thanks
Rob

 
maybe resizing the new window with javascript
will do what u want

using
window.resizeTo(x,y)
and
window.moveTo(x,y)

hope this helps ---------------------------------------
wmail.jpg


someone knowledge ends where
someone else knowledge starts
 
I think (hope) this is what you mean:

<form name=&quot;poll_form&quot; method=&quot;post&quot; action=&quot;javascript:OpenPopup('poll.asp?poll_id=1', 'UniqueWindowName')&quot;>

....
</form>

<script language=&quot;javascript&quot;>

function OpenPopup(url, wname)
{
window.open(url, wname, 'width=300 height=300 top=100 left=100');
}
</script>

you can also leave the &quot;'UniqueWindowName'&quot;

<form name=&quot;poll_form&quot; method=&quot;post&quot; action=&quot;javascript:OpenPopup('poll.asp?poll_id=1')&quot;>

....
</form>

<script language=&quot;javascript&quot;>

function OpenPopup(url)
{
window.open(url, '', 'width=300 height=300 top=100 left=100');
}
</script>

Hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Thanks Boomerang - that's what I was after, but unfortunatyly it doesn't post any variables, so I've gone with neverspeels idea!

Thanks!
 
Hi xscape,

There is a way to send the variables to your ASP page:

------------your ASP page 'poll.asp'------------
<%@ Language=VBScript %>

<%
dim sTextbox1
dim sVote

iPollID = Request.QueryString(&quot;poll_id&quot;)
sTextbox1 = Request.QueryString(&quot;t1&quot;)
iVote = Request.QueryString(&quot;vote&quot;)
%>

<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Response.Write(&quot;Poll ID = &quot; & iPollID)
Response.Write(&quot;<br>&quot;)
Response.Write(&quot;Textbox value = &quot; & sTextbox1)
Response.Write(&quot;<br>&quot;)
Response.Write(&quot;Vote value = &quot; & iVote)
%>

</BODY>
</HTML>
------------end ASP page 'poll.asp'------------

<script language=&quot;javascript&quot;>
function OpenPopup()
// The first argument [0] must always be the url.
// The second argument [1] must always be the formname.
// The third en further arguments [2+]are formfieldnames who's
// value must be submitted.
{
var elObj = new Object()
var elName
var elValue
var NrArg = OpenPopup.arguments.length;
var url = OpenPopup.arguments[0];
//ia=2 because formfields starts in arguments[2].
for (ia=2; ia<NrArg; ia++)
{
elObj = eval('document.' + OpenPopup.arguments[1] + '.' + OpenPopup.arguments[ia]);
if (elObj.length > 0) // formfields with the same name.
{
if (elObj[0].type == 'radio')
{
for (ib=0; ib<elObj.length; ib++)
{
if (elObj[ib].checked)
{
elName = elObj[ib].name
elValue = elObj[ib].value;
}
}
}
}
else // formfields with unique name.
{
elName = elObj.name;
elValue = elObj.value;
}
if (url.indexOf('?') > 0) //check if variables are allready in url
{
url = url + '&'
}
else
{
url = url + '?'
}
url = url + elName + '=' + elValue
}
window.open(url, '', 'width=300, height=300, top=100, left=100, location=yes');
}
</script>

<form name=&quot;webform1&quot; action=&quot;javascript:OpenPopup('poll.asp?poll_id=1', 'webform1', 't1', 'vote');&quot;><br>
<input name=&quot;t1&quot;><br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;1&quot;>Excellent<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;2&quot;>Very Good<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;3&quot;>Average<br>
<input type=&quot;radio&quot; name=&quot;vote&quot; value=&quot;4&quot;>Poor<br>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Vote!&quot;>
</form>

Hope this helps,
Erik <!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (!! Many Happy Returns !! -->
 
Wow, that's some piece of code you've got there. Nice one, cheers, I'll give it a go!

Thanks! (have a star!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top