Okay, I've gotten it to work now...

Javascript as follows:

<script language="JavaScript" type="text/JavaScript">

function Preview() { 
//'LetterPreview','toolbar=yes,location=yes,status=yes,menubar=yes,scrol
lbars=yes,resizable=yes'
var previewWindow;

previewWindow =
window.open("","LetterPreview","toolbar=no,location=no,status=no,menubar
=no,scrollbars=yes,resizable=no,height=600,width=525");

document.Letter.action = "letterPreview.cfm";
document.Letter.target = "LetterPreview";
document.Letter.submit();
//document.Letter.action="letterPreview.cfm";
//document.Letter.submit()
return true;
}

function Send() {
document.Letter.action = "letterSendUpdate.cfm";
document.Letter.target = "_self";
document.Letter.submit();
return true;
}
//-->
</script>

And the button code:


> -----Original Message-----
> From: Jon Hall [mailto:[EMAIL PROTECTED]] 
> Sent: Sunday, December 15, 2002 6:24 PM
> To: CF-Talk
> Subject: Re: Mildly OT: JS, Form, Passing Vars
> 
> 
> The opener stays should stay as is. There is a problem with my code
> though that I didn't see until now. The elem.target should be changed
> to '' if elem.type = complete, because if the close the window after
> previewing, the target needs to be reset. Also the onclick event may
> need to return true for the form to actually submit. I didn't test
> this :) onclick="setFormParams(this.form, 'complete'); return true;"
> 
> If he wants to have a close window button that submits the opener form
> I'd do something line
> opener.setFormParams(opener.forms.letter,'complete') from the popup.
> 
> In thinking about it again, the problem with this method is that you
> still want to control the size of the popup. Probably the best way to
> solve that using this method would be to create the window named "new"
> before submitting the form.
> 
> So a somewhat debugged version might look like this.
> 
> <script>
> function setFormParams(elem, type) {
>   if (type == 'preview') {
>      elem.action = 'letterPreview.cfm';
>      elem.target = 'new';
>   else if (type == 'complete') {
>      elem.action = 'completeForm.cfm';
>      elem.target = '';
> }
> window.open('null.htm','new', ...)
> elem.submit();
> </script>
> 
> <form id="letter">
> <input type="submit" id="preview" value="preview" 
> onclick="setFormParams(this.form, 'preview'); return true">
> <input type="submit" id="complete" value="sumbit" 
> onclick="setFormParams(this.form, 'complete'); return true">
> </form>
> 
> -- 
> jon
> mailto:[EMAIL PROTECTED]
> 
> Sunday, December 15, 2002, 5:36:53 PM, you wrote:
> 
> G> ----- Original Message -----
> G> From: "Jon Hall" <[EMAIL PROTECTED]>
> >> Your making it to complex I think. Just submit the form using
> >> target="new". Something like this...
> >>
> >> <script>
> >> function setFormParams(elem, type) {
> >>   if (type == 'preview') {
> >>      elem.action = 'letterPreview.cfm';
> >>      elem.target = 'new';
> >>   else if (type == 'complete') {
> >>      elem.action = 'completeForm.cfm';
> >> }
> >> elem.submit();
> >> </script>
> >>
> >> <form id="letter">
> >> <input type="submit" id="preview" value="preview"
> G> onclick="setFormParams(this.form, 'preview')">
> >> <input type="submit" id="complete" value="sumbit"
> G> onclick="setFormParams(this.form, 'complete')">
> >> </form>
> G> ----------------------------
> 
> G> I'm curious (and too immersed in something else to set up 
> a test ;-)... What
> G> happens to the opener, the parent window contents, when 
> you submit to the
> G> preview pop-up? Does the browser know not to reload 
> anything into here when
> G> it's submitted a form to another window?
> 
> G> Gyrus
> G> [EMAIL PROTECTED]
> G> work: http://www.tengai.co.uk
> G> play: http://www.norlonto.net
> G> PGP key available
> 
> G> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to