View Full Version : Need some script help

01-03-2006, 02:17 PM
I have a form that on click validates that form and then emails the data and redirects them to a new page within the same browser window. Is there a way to make the submit button pull up a new window when redirecting?
Here is some of the code for the submit button and hidden fields. Don't know if it will help but it might. Thanks,

<input name="Submit" type="submit" onClick="MM_validateForm('Zip Code24','','RisNum','Email23','','RisEmail');retur n document.MM_returnValue" value="Submit">
<input name="Clear Form22" type="reset" id="Clear Form23" value="Reset">
<input type="hidden" name="email_From" value="Coupon@requests.com">
<input type="hidden" name="email_To" value="alex@petsincredible.com">
<input type="hidden" name="email_Subject" value="Coupon Form Submission">
<input type="hidden" name="email_ThankYou" value="Thank you for submitting your request.">
<input type="hidden" name="email_Redirect" value="http://www.PetsIncredible.com/documents/coupon_book_v2.pdf">

01-03-2006, 03:52 PM
ic you have the code below for a submit button

<input name="Submit" type="submit" onClick="MM_validateForm('Zip Code24','','RisNum','Email23','','RisEmail');retur n document.MM_returnValue" value="Submit">

i would change that to a button instead of a submit then at the bottom of your MM_validateForm function just add <span style='color:red'>document.form1.submit(); </span>just before the last <span style='font-size:14pt;line-height:100%'>}</span>


function MM_validateForm(a,b,c,d,e){

validateform stuff;
validateform stuff;
validateform stuff;
validateform stuff;

window.open("", "NewWin", 'toolbar,width=150,height=100')



as you can see from the example i am validating the form then opening the window then submitting the form all from 1 function

try to submit forms like this through Javascript as you have more controll over them

also by submitting them through a function you can utilise things like..

document.form1.action = "process1.php";
rather than setting this within the form tag as this way you can make the processing page dynamic by changing the action value on an IF statement or a switch

01-03-2006, 06:57 PM
I have found a way using the submit button to open a new window. The problem is the validation is on the onclick="" and so is the MM_openBrWindow. So if someone just clicks the submit button it pops up a window that says form missing.....but then it opens the new window anyway. How can I change that - is there an onvalidation script? or can I use an "if" statement that says if form is valid then open new window? I'm not that good at javascript, so I am unsure where to go. Anyway, here is the code. Thanks

<input name="Submit" type="submit" onClick="MM_validateForm('Zip Code24','','RisNum','Email23','','RisEmail');MM_op enBrWindow('http://www.website.com','Coupons','toolbar=yes,location=y es,status=yes,
menubar=yes,scrollbars=yes,resizable=yes,width=700 ,height=700');return document.MM_returnValue" value="Submit">

01-04-2006, 08:10 AM
the way you are doing it is it is going to submit the form anyway then it will fire the onclick and validate after it has submited the form

change the submit to a button as i have said and fire all the actions from within the one function