2

I am currently using the dotmailer to generate a new form (simple textbox and submit button) that automatically adds the email address to the dotmailer address book.

When someone submits an email address - they can be taken to a webpage.

<input type="hidden" name="ReturnURL" id="returnValueHidden" value="URL">

I have been trying to work out a way to present an alert box saying "submitted" and not take take the user to a thank you page.

Solution?

document.getElementById('returnValueHidden').value = alert("Email successfully submitted.");

But all this does, it displays an alert box and then redirects to the following url (even when the value is inserted or not).

http://dmtrk.net/undefined?result=success
404 The page you are looking for could not be found

Is there anyway i can adjust this so it submits the email but does not redirect.

Full Code:

<script language="javascript">
<!--
function validate_signup(frm) {
var emailAddress = frm.Email.value;
var errorString = '';
if (emailAddress == '' || emailAddress.indexOf('@') == -1) {
errorString = 'Please enter your email address';
}


var els = frm.getElementsByTagName('input');
for (var i = 0; i < els.length; i++)
{
    if (els[i].className == 'text' || els[i].className == 'date' || els[i].className == 'number')
    {
        if (els[i].value == '')
            errorString = 'Please complete all required fields.';
    }
    else if (els[i].className == 'radio')
    {
        var toCheck = document.getElementsByName(els[i].name);
        var radioChecked = false;
        for (var j = 0; j < toCheck.length; j++)
        {
            if (toCheck[j].name == els[i].name && toCheck[j].checked)
                radioChecked = true;
        }
        if (!radioChecked)
            errorString = 'Please complete all required fields.';
    }
}

document.getElementById('returnValueHidden').value = alert("Email successfully submitted.");


var isError = false;
    if (errorString.length > 0)
        isError = true;

    if (isError)
        alert(errorString);
return !isError;
}


//-->
</script> 

HTML:

<form name="signup" id="signup" action="http://dmtrk.net/signup.ashx" method="post" onsubmit="return validate_signup(this)">
<input type="hidden" name="addressbookid" value="">
<input type="hidden" name="userid" value="41929">
<input type="hidden" name="ReturnURL" id="returnValueHidden" value="URL">

<input type="text" name="Email" onfocus="if(this.value=='Email')this.value='';" class="blueTextBox">

<input type="Submit" name="Submit" class="submit">
</form>
Sophie Rhodes
  • 2,079
  • 2
  • 17
  • 29
jagmitg
  • 2,061
  • 2
  • 17
  • 31

1 Answers1

1

To send information without doing a full page reload you need to use AJAX. It's easiest to use an existing javascript library, for example jQuery.

Check out these pages:

Dragony
  • 1,644
  • 10
  • 19