Print Page | Close Window

`Submit` changing roles

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2748
Printed Date: 29 March 2026 at 7:39pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: `Submit` changing roles
Posted By: Munk
Subject: `Submit` changing roles
Date Posted: 15 May 2003 at 9:34pm

I'm hoping that some of you WWG Forums gurus might have an answer here, although the question is more just ASP, so I'm posting it in here...

I'm working on a poetry submission area for my site, and I'm trying to incorporate the same type of processing as what WWG has in it's forums. On the poem editor, I have a preview, clear form, and submit, much like the forums. My problem is that is you click preview first (which works fine opening its own window), the submit function will also open the preview window afterwards. If you submit the poem without clicking the preview button, it submits just fine.

I have the buttons setup just like the forums, but can't get the submit to keep it's role consistent, no matter how many brain cells I fry trying to figure this out.  I'm hoping this to be more of a general issue, so I'm not posting code that most of you have possibly already seen many times. If I need to, though, I will...

Thanks in advance for any helpful info on this one!



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown



Replies:
Posted By: MorningZ
Date Posted: 16 May 2003 at 7:29am
lets see some code!

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: fernan82
Date Posted: 16 May 2003 at 6:43pm

yea it would be helpful if you post the code...



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Munk
Date Posted: 16 May 2003 at 6:46pm

I've taken out the table formatting to save space, since it's irrelevant...  here's what I have, very simple form setup (or so I thought it would be  ). I have the form-check function and reset here, the form, with a preview button, which opens a preview, much like the forums do. I even put the poem editor in an iframe like the forums. Maybe that has something to do with it? Who knows...  like I said, if I don't preview first, the form submits perfectly. If I preview first, after closing the preview window, the submit button actually does the exact same thing as the preview button, and opens the preview window/code.

 

<SCRIPT Language=Javascript>

function ResetForm(){

       if (window.confirm('<% = strResetFormConfirm %>')){
              frames.poem.focus();
              frames.poem.document.body.innerHTML = '';
              return true;
        }
        return false;            
}

 

function CheckForm()
{   var returnValue = false;
    if (document.frmAddPoem.title.value == "")
     { alert('A Poem isn`t a poem with a title...','Form Error');
     document.frmAddPoem.title.focus(); }
    else { returnValue = true; }
       return returnValue;
}

</SCRIPT>

 

<form method="post" name="frmAddPoem" action="poetry_submit.asp" onSubmit="return CheckForm();" onReset="return ResetForm();">

 

<input type="hidden" name="poem" value="" />

<input type="hidden" name="browser" value="IE" />

 

<script language="javascript">

document.write ('<iframe src="poem_textbox.asp?pb=<%= strPoemBack %>" id=

-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown



Posted By: fernan82
Date Posted: 16 May 2003 at 7:09pm

Give this a try:

 

<SCRIPT Language=Javascript>

function ResetForm(){

       if (window.confirm('<% = strResetFormConfirm %>')){
              frames.message.focus();
              frames.message.document.body.innerHTML = '';
              return true;
        }
        return false;            
}

 

function CheckForm()
{   var returnValue = false;
    document.frmAddPoem.poem.value = frames.poem.document.body.innerHTML;
    if (document.frmAddPoem.title.value == "")
     { alert('A Poem isn`t a poem with a title...','Form Error');
     document.frmAddPoem.title.focus(); }
    else { returnValue = true; }
       return returnValue;
}


</SCRIPT>

 

<form method="post" name="frmAddPoem" action="poetry_submit.asp" onSubmit="return CheckForm();" onReset="return ResetForm();">

 

<input type="hidden" name="poem" value="" />

<input type="hidden" name="browser" value="IE" />

 

<% Randomize Timer %>


<script language="javascript">

document.write ('<iframe src="poem_textbox.asp?pb=<%= strPoemBack %>" id="poem" width="500" height="200"></iframe>')

frames.poem.document.designMode = "On";

</script>

 

<input type="button" name="Preview" value="Preview Poem" onClick="document.frmAddPoem.poem.value = frames.poem.document.body.innerHTML; OpenPreviewWindow('poem_preview.asp?Pback=<%= strPoemBack %>', document.frmAddPoem);" />

<input type="reset" name="Reset" value="<% = strTxtClearForm %>" />

<input type="submit" name="Submit" value="Submit Poem" tabindex="30" />


</form>

 

<edit> nevermind i don't think that's the problem



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Munk
Date Posted: 16 May 2003 at 7:23pm

You're right... it turned out to not be the problem. A good thought, though, and I like that structure a little better, so thanks you in any case  :)

I'm baffled on this one. I may strip it down to trying it without an iframe, for poops and giggles, but in the end I know that's what I want. And since I run WWG forums, I know it can be done LOL.



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown


Posted By: fernan82
Date Posted: 16 May 2003 at 7:32pm
do you have any more forms on the same page? like on the header or footer...?

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Munk
Date Posted: 16 May 2003 at 7:41pm

Nope, sure don't... 'tis a single stand alone form. Basically, I'm setting it up so that the user has a choice of backgrounds, which is the first step. The background code is passed to this page, where there is a single form for editing the poem itself. You can see where I'm passing the background code to the appropriate areas for display while the user writes their poem. The whole thing is only being passed as a string argument as you navigate, so the backgroud code shouldn't even be a problem at all. It's really only used when the entry is added to the DB.  (Aside from display)

and please excuse my typo I made in the JS, when I said 'A poem isn`t a poem with a title'.  That was supposed to be 'without' a title LOL. Shows how late at night I was up playing around with this trying to make it work LOL



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown


Posted By: fernan82
Date Posted: 16 May 2003 at 7:46pm

There's some code missing like the OpenPreviewWindow function is not there, seeing your code i figure you have done changes to that function as well, can you post the whole thing...?



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: Munk
Date Posted: 16 May 2003 at 7:52pm

Sure - At first, as in the first posting, I was pulling the same preview window code that comes with the forums, which is this...

function OpenPreviewWindow(targetPage, formName){

now = new Date

//Open the window first
openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')

//Now submit form to the new window
formName.action = targetPage + "?ID=" + now.getTime();
formName.target = "preview";
formName.submit();
}

Since then, I've made a different copy of it, that doesn't add the time ID for cache purposes. I made it as simple as possible, renamed the functionand the respective calling code, and here that replacement is...  (which, btw, didn't help either)

function OpenPoemPreview(targetPage, formName){
openWin('','preview','toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1,width=680,height=400')
formName.action = targetPage
formName.target = "preview";
formName.submit();
}

Btw.. I do appreciate all of your help looking at this, fernan82 - one day I hope to have a site member gathering, and I'll have to send you an invite so I can buy ya a brew!

<EDIT> I'm getting the actual preview code together so I can post that, too. I can't see any possible reason it should affect it, but hey, if I had the answers, I wouldn't be here right now LOL



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown


Posted By: Munk
Date Posted: 16 May 2003 at 8:05pm

Here's the poem preview code in it's full entirety, with the exception of the DB includes for it.

<% @ Language=VBScript %>
<% Option Explicit %>

<%
Response.Buffer = True

Dim strPoem

Dim strPoemBack
Dim strBGPath
Dim MyQuery

Response.Expires = 0
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "private"

strPoem = Request.Form("poem")
strPoemBack = Request.Form("new_poem_back")

if strPoemBack = "No Background" Then strPoemBack = ""
if strPoemBack <> "" Then
MyQuery = "SELECT BG_Name, Path FROM Backs WHERE BG_Name = '" & strPoemBack & "'"
Call OpenDBPoems
poemRS.Open MyQuery
if NOT poemRS.EOF Then
strBGPath = poemRS("Path")
poemRS.Close
Call CloseDBPoems
else
strBGPath = strPoemBack
Call CloseDBPoems
end if
end if

If Request.Form("browser") = "IE" Then

strPoem = WYSIWYGFormatPost(strPoem)

Else
strPoem = FormatPost(strPoem)
End If

strPoem = checkHTML(strPoem)

If strPoem = "" OR IsNull(strPoem) Then
strPoem = "<br /><br /><div align=""center"">" & strTxtThereIsNothingToPreview & "</div><br /><br />"
End If

Set rsCommon = Nothing
adoCon.Close
Set adoCon = Nothing
%>
<html>
<head>
<title>Poem Preview</title>
<HTTP-EQUIV=
"PRAGMA" CONTENT="NO-CACHE">

<!--#include file="includes/skin_file.asp" -->
</head>
<body bgcolor=
"<% = strBgColour %>" text="<% = strTextColour %>" background="<% = strBgImage %>" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" OnLoad="self.focus();">
<table width="<% = strTableVariableWidth %>" border="0" cellspacing="0" cellpadding="1" align="center" height="53">
<tr>
<td align="center" height="17"><span class="heading">Poem Preview</span></td>
</tr>
<tr>
<td align="center" height="39"><a href="JavaScript:onClick=window.close()">Close Preview Window</a></td>
</tr>
</table>
<table width="<% = strTableVariableWidth %>" border="0" cellspacing="0" cellpadding="1" bgcolor="<% = strTablePostsBorderColour %>" align="center">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="<% = strTablePostsEvenRowColour %>" background="<% = strBGPath %>" height="147">
<tr>
<td class="text" valign="top">
<% = strPoem %>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="<% = strTableVariableWidth %>"

-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown



Posted By: Munk
Date Posted: 16 May 2003 at 8:24pm

Actually... I think I'm onto something. When the preview code is called, it's basically redefining the forms 'action' attribute to be the preview page title... so when returning to the main page, the form still has that attribute when it's submitted with the submit button.

Now all I need to do is figure out how boRg is handling that LOL



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown


Posted By: Munk
Date Posted: 16 May 2003 at 8:41pm

WOO HOOOO !  I got it - the two additional lines added to the CheckForm function resets the form's attributes to the original, hence allowing the form to process correctly when returning to it.

Here the new code....

function CheckForm()
{ var returnValue = false;
document.frmAddPoem.poem.value = frames.poem.document.body.innerHTML;
if (document.frmAddPoem.title.value == "")
{ alert('A Poem isn`t a poem without a title...','Form Error');
document.frmAddPoem.title.focus(); }
else {
returnValue = true;
document.frmAddPoem.action="poetry_submit.asp"
document.frmAddPoem.target="_top"

}
return returnValue;
}



-------------
~~Munk~~

'The details are the jungle in which the Devil hides... the only salvation lies in structure' - Author Unknown



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net