Good day every body, this my script can submit form inputs to email.but i wants it to equally display another page on submit.to this effect i have add this code below to the body of the main code but its not working.U can see where i added it at bottom of the body element

<body onsubmit="javascript:window.location.href='dload.html';">

here is the main code. thanks

<html><head><title>gggggg</title>

<script type="text/javascript">

function clear_field(field)
{
    if (field.value==field.defaultValue)
    {
        field.value=''
    }
}
// Checks field to see if any information was entered. If not, the default value is reentered.
function check_field(field)
{
    if (field.value=='' ||
    field.value==' ')
    {
        field.value=field.defaultValue
    }
}
// Validates the form. If a field fails the validation, The form is not submitted.
function validate_form()
{
// Validates the name field.
    if (document.jsform.lastname.value==document.jsform.lastname.defaultValue ||
    document.jsform.lastname.value.indexOf(' ',0)==0)
    {
        alert('\nNo lastname entered.')
        document.jsform.lastname.select()
        document.jsform.lastname.focus()
        return false
    }
// Validates the firstname field.
    if (document.jsform.firstname.value==document.jsform.firstname.defaultValue ||
    document.jsform.lastname.value.indexOf(' ',0)==0)
    {
        alert('\nNo firstname entered.')
        document.jsform.firstname.select()
        document.jsform.firstname.focus()
        return false
    }
// Validates the email field.
    if (document.jsform.email.value==document.jsform.email.defaultValue)
    {
        alert('\nNo email address entered.')
        document.jsform.email.select()
        document.jsform.email.focus()
        return false
    }
        if (document.jsform.email.value.indexOf('@',0)==-1 ||
        document.jsform.email.value.indexOf('.',0)==-1)
        {
            alert('\nInvalid email address.')
            document.jsform.email.select()
            document.jsform.email.focus()
            return false
        }
// Validates the comments field.
    if (document.jsform.COMMENTS.value==document.jsform.COMMENTS.defaultValue ||
    document.jsform.COMMENTS.value.indexOf(' ',0)==0)
    {
        alert('\nNo COMMENTS entered.')
        document.jsform.COMMENTS.select()
        document.jsform.COMMENTS.focus()
        return false
    }
// Validates the gender field.
    if (document.jsform.gender.value==document.jsform.gender.defaultValue ||
    document.jsform.gender.value.indexOf(' ',0)==0)
    {
        alert('\nNo gender entered.')
        document.jsform.gender.select()
        document.jsform.gender.focus()
        return false
    }
// Validates the select field.
    if (document.jsform.copy.value==document.jsform.copy.defaultValue ||
    document.jsform.copy.value.indexOf(' ',0)==0)
    {
        alert('\nNo answer entered.')
        document.jsform.copy.select()
        document.jsform.copy.focus()
        return false
    }
// Prompts user for confirmation
    else
    {
        if(confirm('\nClick the OK button to send this form via email.'))
        {
            return true
        }
        else
        {
            return false
        }
    }
}
</SCRIPT>


</head>

<font color=green>


<fieldset><legend>USERS COMMENTS</legend>
<FORM NAME='jsform'    METHOD='post'    ENCTYPE='text/plain'    ACTION='mailto:esedofred@yahoo.com?subject=hello esedo'    onSubmit='return validate_form()'>
<INPUT NAME='lastname'    TYPE='text'    VALUE='your lastname'    SIZE='50'    onFocus='clear_field(this)'    onBlur='check_field(this)'></br>
<INPUT NAME='firstname'    TYPE='text'    VALUE='your firstname'    SIZE='50'    onFocus='clear_field(this)'    onBlur='check_field(this)'></br>
<INPUT NAME='email'    TYPE='text'    VALUE='Email address'    SIZE='50'    onFocus='clear_field(this)'    onBlur='check_field(this)'></br>
<TEXTAREA NAME="COMMENTS" ROWS=6 COLS=38  VALUE='your comment'  onFocus='clear_field(this)'    onBlur='check_field(this)'></TEXTAREA></br>Enter your comments in the box provided.</br>
<INPUT NAME='gender'    TYPE='text'    VALUE='gender'    SIZE='5'    onFocus='clear_field(this)'    onBlur='check_field(this)'></br> 
Do you like our site </br>
<SELECT NAME='Copy'>    
<OPTION SELECTED VALUE='yes'>yes  
<OPTION VALUE='no'>no</SELECT>
<INPUT TYPE='submit'    VALUE='Submit'>
<INPUT TYPE='reset'    VALUE='Reset'></br>
</FORM>
</fieldset>
if you made any mistake click on RESET BUTTON to refresh.
</font>

<body onsubmit="javascript:window.location.href='dload.html';">
</body>

Server-side scripting can easily do what you want.

On the client side, a FORM cannot have more than one ACTION=.

One workaround (there are others) is to separate the steps. At the end of the validation routine this

var mailto_string = 'mailto:'+your_email+'?subject='+your_subject+'&body='+your_choice_of_fields;

    var eml = window.open(mailto_string,'emlWin'); 
    if (eml && eml.open && !eml.closed) eml.close(); 
    location.href='http://www.google.com'

will open a new window and immediately close it (leaving the the user's email program of choice [assuming that there is one] with the values you provided already plugged into a message and waiting for the user to review and/or edit and hit send. Meanwhile the desired URL opens in the browser.

Thanks very much

I have realted problem. I need to open a document on click of button. I used window.open(). it does not work for IE6 only. So what alternative method I can use to resolve this issue.
I have tried window.location but in this case I can not attache form bean. so my app gives error.

You have an entirely different problem.
And you have already started another thread for it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.