Getting Params from Form

Hi,

I've built a form that will send an email. I placed a button on the form which allows you to preview the email before it's sent. This preview is opened in a new window...

<script>

function previewEmail(){

document.forms[0].enctype ='application/x-www-form-urlencoded';

document.forms[0].action ='preview.jsp';

window.open(document.forms[0].action,'preview','width=700,height=500,resizable,scrollbars');returnfalse;

document.forms[0].target ='preview';

document.forms[0].submit();

}

</script>

.

.

.

<form name="form1" method="post" action="send_mail.jsp" enctype="multipart/form-data">

.

.

.

<input type="button" name="Submit" value="Preview" onClick="previewEmail();">

The javascript opens the window correctly, but the params from the form are not coming through.

I've tried accessing them like...

${param.paramName}

and...

${pageScope.param.paramName}

but both ways they show up empty.

Any help would be greatly appreciated!!!

[1687 byte] By [bigDa] at [2007-10-2 13:35:23]
# 1

The problem is this line:

window.open(document.forms[0].action,'preview','width=700,height=500,resizable,scrollbars'); return false;

The first parameter to window.open is the url to display. This will invoke preview.jsp with no parameters. You then have a semi-colon and a "return false;" which will exit the function. The document submission which would have invoked preview.jsp with parameters is never invoked.

Gita_Weinera at 2007-7-13 11:23:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Ahh, thanks Gita_

I just had my javascript commands out of order. Works when I do this:

function previewEmail() {

window.open('about:blank','preview','width=700,height=500,resizable,scrollbars');

document.forms[0].enctype = 'application/x-www-form-urlencoded';

document.forms[0].method = 'get';

document.forms[0].action = 'preview.jsp';

document.forms[0].target = 'preview';

document.forms[0].submit();

return false;

}

bigDa at 2007-7-13 11:23:58 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...