View Full Version : Form Submit...
Ph45mA
02-16-2003, 04:09 AM
Curious as to how this would be done. If it could be done. As I am an amateur at Javascripting.
I have a VERY basic form
<form method="post" action="vote.asp">
<input type="radio" value="A" name="u_input">A<br>
<input type="radio" value="B" name="u_input">B<br>
<input type="radio" value="C" name="u_input">C<br>
<input type="radio" value="D" name="u_input">D<br>
<input type="submit" value="Submit" >
</form>
And I am curious as to how I would make it so that when the "Submit" button is pressed. The action "vote.asp" would open up in a popup with no toolbars, status bar, buttons, etc.
Thank you very much.
~Ph45mA
brothercake
02-16-2003, 04:25 AM
I *think* you can do something like this:
<form method="post" action="vote.asp" target="newWin" onsubmit="return submitForm()">
then you go:
function submitForm() {
//validate form
if(some_conditions){
var newWin = open("","newWin","properties"); // open the new window
return true; //submit the form
}
else {
alert("you didn't do [something]"); // alert message
return false; // don't submit the form
}
Ph45mA
02-16-2003, 04:40 AM
Ph45mA
02-16-2003, 04:44 AM
Hrm. Well that may just do it. Testing it
brothercake
02-16-2003, 04:46 AM
Are you validating by HTTP REFERER? Javascript form submission might not send referer information with POST data ... not sure ... maybe try GET
Ph45mA
02-16-2003, 04:48 AM
Not working. I'll fool around with it though. Dont worry 'bout it. I think my ASP script is fubar'd. Its not saving incrementing variables properly at the moment.
~Ph45mA
whammy
02-16-2003, 03:56 PM
I have a solution for you. What you can do is post the page to itself... then, depending upon whether it's been posted, you display different HTML.
<%
Dim u_input, submitnumber
u_input = Request.Form("u_input')
submitnumber = Request.Form("submitnumber")
submitnumber = submitnumber + 1
If submitnumber > 1 AND Len(u_input) > 0 Then
' Display a subroutine which includes all of the HTML
' and javascript to popup the window, etc.
' like this:
Call DisplayVoteResults()
Else
' Display the HTML form again that asks them to vote
' letting them know that they need to select an answer
Call DisplayForm()
End If
%>
<% Sub DisplayForm() %><html>
<head>
<title></title>
</head>
<body>
<form id="form1" method="post" action="vote.asp">
<input type="radio" value="A" name="u_input" />A<br />
<input type="radio" value="B" name="u_input" />B<br />
<input type="radio" value="C" name="u_input" />C<br />
<input type="radio" value="D" name="u_input" />D<br />
<input type="hidden" name="submitnumber" value="<% = submitnumber %>" />
<input type="submit" value="Submit" >
</form>
</body>
</html><% End Sub %>
<% Sub DisplayVoteResults() %><html>
<head>
<title></title>
<!-- put javascript here to do the popup onload maybe -->
</head>
<body>
<!-- You could also put javascript here to open the vote popup.
Easiest way is probably to have another .asp page
which accepts the querystring variable, and use
javascript to pop it open like:
window.open('whatever.asp?u_input=<% = u_input %>')
I would probably also pass their UserID (if they are logged in
or something) to "whatever.asp" and check for
that so they can't vote twice, or implement some
solution to prevent them double voting... probably no
totally foolproof way to do that,
a cookie should be ok, perhaps?
-->
</body>
</html><% End Sub %>
:)
Ph45mA
02-16-2003, 04:50 PM
Ill fiddle around with that code. Thanks much whammy :)
~Ph45mA
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.