JQuery Challenge

Hi Experts,

I'm a little rusty on JQuery and trying to update some code from a few years ago, but not getting the result i want..

I have three files -

The Form
The JQuery
The VbScript

The form allows the user to sign up for email alerts - there are 2 forms (if /else) depending on user access -

<% if ResultsCount >= 10 then %>
<% If (Request("Region") <> "") OR (Request("Sector") <> "") OR (Request("Location") <> "") OR (Request("id") <> "") then %>
<!--% If (Request("clientid") = "") AND (Request("jobtype") = "") AND (Request("hours") <> "") AND (Request("keywords") <> "") then %-->
<%if Session("UID") = ""  then %>
<form action="" name="EmailAlertsForm" id="EmailAlertsForm" class="EmailAlertsForm clearfix">
  <legend>Get <%=(MetaPage)%> emailed job alerts
  <input name="Validated" type="hidden" id="JBEValidated" value="N">
  <input type="hidden" name="Sector" id="JBESector" value="<%=Request("Sector")%>">
  <input type="hidden" name="Region" id="JBERegion" value="<%=Request("Region")%>">
  <input type="hidden" name="Location" id="JBELocation" value="<%=Request("Location")%>">
  </legend>
  <label for="email">Get the latest <%=(MetaPage)%> direct to your inbox</label>
  <div style="float: left; width: 278px; padding: 0px 4px 4px 4px; margin-top: 8px; background-color: #608EC7; border-radius: 4px;">
  <div style="float:left; width:236px; padding-top:4px;">
  <input name="email" type="email" required id="JBEemail" placeholder="Email address" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" maxlength="255"/>
  </div>
  <div style="float: left; width: 42px; padding-top: 5px;">
  <input name="EmailSignUp" type="submit" disabled="disabled" id="EmailSignUp"  value="GO"/>
  </div>
  </div>
  <!--div class="paperPlane"></div-->
  <div class="clearfix"></div>
</form>
<div id="EmailAlertsFormSuccess" style="display:none;"></div>
<%Else%>
<form action="" name="EmailAlertsForm" id="EmailAlertsFormRegistered" class="EmailAlertsForm clearfix">
  <legend>Get <%=(MetaPage)%> emailed job alerts
  <input name="Validated" type="hidden" id="JBEValidated" value="Y">
  <input type="hidden" name="Sector" id="JBESector" value="<%=Request("Sector")%>">
  <input type="hidden" name="Region" id="JBERegion" value="<%=Request("Region")%>">
  <input type="hidden" name="Location" id="JBELocation" value="<%=Request("Location")%>">
  </legend>
  <label for="email2">Get the latest <%=(MetaPage)%> direct to your inbox</label>
    <div style="float: right; width: 96px; padding: 0px 2px 4px 2px; margin-top: 8px; background-color: #608EC7; border-radius: 4px;">
    <div style="float:left; width:96px; padding-top:4px;">
    <input name="EmailSignUp2" type="submit" id="EmailSignUp2"  value="Notify Me !" disabled="disabled" style="float:right"/>
    </div>
    </div>
    
  <!--div class="paperPlane"></div-->
</form>
<div id="EmailAlertsFormSuccess" style="display:none;"></div>
<!--%End if%-->
<%End if%>
<%End if%>
<%End if%>

Open in new window


When the user clicks on the submit button the JQuery below should be triggered

$("#EmailAlertsForm, #EmailAlertsFormRegistered").submit(function () {
var email = $("#JBEemail").val();
var UserID = $("#JBEUserID").val();
var Validated = $("#JBEValidated").val();
var Sector = $("#JBESector").val();
var Region = $("#JBERegion").val();
var Location = $("#JBELocation").val();
var datastring = $("#EmailAlertsForm, #EmailAlertsFormRegistered").serialize();

if(email=='' || UserID=='') {
$('.error').fadeOut(200).show();
}
else {
$.ajax({
    type: "POST",
    url: "/actions/jbe.asp",
    data: dataString,
    success: function () {
$('.EmailAlertsForm').fadeOut(200).hide();
$('#EmailAlertsFormSuccess').fadeIn('slow');
if(UserID=='') {
$('#EmailAlertsFormSuccess').html('<span>' + email + '</span><br /><p>We have added ' + Sector + 'jobs ' + Region +', ' + Location +' to your alerts</p><div class="clearfix"></div>');
}
else{
$('#EmailAlertsFormSuccess').html('<span>Job Done !</span><p>We\'ll send you daily alerts about the latest ' + Sector + 'jobs in ' + Region +', ' + Location +' but before we do, please click the link on the email we have sent you to validate this email alert</p><div class="clearfix"></div>');
}
}
});
}
return false;
});

Open in new window


Which runs the following vbscript -

<%

Dim CMDJobsbyEmailSetup__UserID
CMDJobsbyEmailSetup__UserID = NULL
if(Session("UID") <> "") then CMDJobsbyEmailSetup__UserID = Session("UID")

Dim CMDJobsbyEmailSetup__Username
CMDJobsbyEmailSetup__Username = NULL
if(Request("Username") <> "") then CMDJobsbyEmailSetup__Username = Request("Username")

Dim CMDJobsbyEmailSetup__Region
CMDJobsbyEmailSetup__Region = NULL
if(Request("Region") <> "") then CMDJobsbyEmailSetup__Region = Request("Region")

Dim CMDJobsbyEmailSetup__Location
CMDJobsbyEmailSetup__Location = NULL
if(Request("Location") <> "") then CMDJobsbyEmailSetup__Location = Request("Location")

Dim CMDJobsbyEmailSetup__Sector
CMDJobsbyEmailSetup__Sector = NULL
if(Request("Sector") <> "") then CMDJobsbyEmailSetup__Sector = Request("Sector")

set CMDJobsbyEmailSetup = Server.CreateObject("ADODB.Command")
CMDJobsbyEmailSetup.ActiveConnection = MM_jobster_STRING
CMDJobsbyEmailSetup.CommandText = "dbo.JobsterCandidateRegisterJobsByEmail"
CMDJobsbyEmailSetup.CommandType = 4
CMDJobsbyEmailSetup.CommandTimeout = 0
CMDJobsbyEmailSetup.Prepared = true
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@RETURN_VALUE", 3, 4)
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@UserID", 3, 1,4,CMDJobsbyEmailSetup__UserID)
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@Username", 200, 1,350,CMDJobsbyEmailSetup__Username)
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@Region", 200, 1,50,CMDJobsbyEmailSetup__Region)
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@Location", 200, 1,50,CMDJobsbyEmailSetup__Location)
CMDJobsbyEmailSetup.Parameters.Append CMDJobsbyEmailSetup.CreateParameter("@Sector", 200, 1,50,CMDJobsbyEmailSetup__Sector)
set JBESetup = CMDJobsbyEmailSetup.Execute
JBESetup_numRows = 0

If not JBESetup.eof then
arrsetupJBE = JBESetup.GetRows()
End if 

JBESetup.Close() 'Clean Up
Set JBESetup = Nothing 'Clean Up
Set CMDJobsbyEmailSetup = Nothing 'Clean Up

If IsArray(arrsetupJBE) Then
Dim result
if arrsetupJBE(0,0) = 1 then
result = 1
Dim objCDOSYSMail
Set objCDOSYSMail = CreateObject("CDO.Message")
Dim objCDOSYSCon
Set objCDOSYSCon = CreateObject ("CDO.Configuration")

objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.net"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") ="apikey"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxxxx"
objCDOSYSCon.Fields.Update

Set objCDOSYSMail.Configuration = objCDOSYSCon
URLShort="New Job Alert Request - testsite.co.uk"
'URLLong="http://testsite.co.uk/coms/js/unregisteredjobalert.asp?"
ReplyMail="test.user@testsite.co.uk"
ToMail="no-reply@testsite.co.uk"
FromMail="""testsite"" <job-alerts@testsite.co.uk>"
objCDOSYSMail.From = FromMail
objCDOSYSMail.To = ToMail
objCDOSYSMail.ReplyTo= ReplyMail
objCDOSYSMail.Subject = URLShort
objCDOSYSMail.TextBody = "This is a message"
objCDOSYSMail.Send
Set objCDOSYSMail = Nothing
Set objCDOSYSCon = Nothing

Elseif arrsetupJBE(0,0) = 2 then
result = 2
Dim objCDOSYSMail2
Set objCDOSYSMail2 = CreateObject("CDO.Message")
Dim objCDOSYSCon2
Set objCDOSYSCon2 = CreateObject ("CDO.Configuration")

objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.net"
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") ="apikey"
objCDOSYSCon2.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxxxx"
objCDOSYSCon2.Fields.Update

Set objCDOSYSMail2.Configuration = objCDOSYSCon2
URLShort="New Job Alert Request - testsite.co.uk"
'URLLong="http://testsite.co.uk/coms/js/unregisteredjobalert.asp?"
ReplyMail="test.user@testsite.co.uk"
ToMail="no-reply@testsite.co.uk"
FromMail="""testsite"" <job-alerts@testsite.co.uk>"
objCDOSYSMail2.From = FromMail
objCDOSYSMail2.To = ToMail
objCDOSYSMail2.ReplyTo= ReplyMail
objCDOSYSMail2.Subject = URLShort
objCDOSYSMail2.TextBody = "This is a message"
objCDOSYSMail2.Send

Set objCDOSYSMail2 = Nothing
Set objCDOSYSCon2 = Nothing

Elseif arrsetupJBE(0,0) = 3 then
result = 3

Dim objCDOSYSMail3
Set objCDOSYSMail3 = CreateObject("CDO.Message")
Dim objCDOSYSCon3
Set objCDOSYSCon3 = CreateObject ("CDO.Configuration")

objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.server.net"
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") ="apikey"
objCDOSYSCon3.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxxxx"
objCDOSYSCon3.Fields.Update

Set objCDOSYSMail3.Configuration = objCDOSYSCon3
URLShort="New Job Alert Request - testsite.co.uk"
'URLLong="http://testsite.co.uk/coms/js/unregisteredjobalert.asp?"
ReplyMail="test.user@testsite.co.uk"
ToMail="no-reply@testsite.co.uk"
FromMail="""testsite"" <job-alerts@testsite.co.uk>"
objCDOSYSMail3.From = FromMail
objCDOSYSMail3.To = ToMail
objCDOSYSMail3.ReplyTo= ReplyMail
objCDOSYSMail3.Subject = URLShort
objCDOSYSMail3.TextBody = "This is a message"
objCDOSYSMail3.Send

Set objCDOSYSMail3 = Nothing
Set objCDOSYSCon3 = Nothing

End if
end if
Response.Write(result)
%>

Open in new window


The vbscript is working fine, when i try submitting the form the page just reloads with additional parameters in the URL, Son I'm guessing the challenge is the JQuery./...

Any ideas?

Thank you
garethtnashAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Couple of quick things to take a look at.

Firstly, your form has no method parameter set, so the default is GET, which is why you're getting the parameters in the URL. You might want to set it to POST:

<form method="post" ...

Secondly, because you're handling the form submit with jQuery, you need to somehow prevent the form from being submitted in the 'normal' way. You do this by calling preventDefault on the event in your jQuery code. THe event is passed in as a argument to the function (e in the example below):

$("#EmailAlertsForm, #EmailAlertsFormRegistered").submit(function (e) {
   e.preventDefault();
   ...

Open in new window

Chris StanyonWebDevCommented:
Couple of other things to check. Make sure your jQuery is wrapped in a document ready block, otherwise it potentially fires before the form is loaded so it would have no effect. Also (may sound obvious) but make sure you're actually loading the jQuery library:

<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
   $("#EmailAlertsForm, #EmailAlertsFormRegistered").submit(function (e) {
      e.preventDefault();
      var email = $("#JBEemail").val();
      ...    
   });
});
</script> 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Thanks Chris, I'll come back to you
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

garethtnashAuthor Commented:
Chris,

Sorry to ask! but now my JQuery file has completely stopped working! Any chance you could have a quick review?

Thanks

v//Google CookieChoise //
document.addEventListener('DOMContentLoaded', function(event) {
cookieChoices.showCookieConsentBar('mysiteUK uses cookies to deliver jobs and content to you, some of the cookies we use are essential for parts of the site to operate.', 'Close', 'Learn more', 'http://www.mysiteUK.co.uk/terms/cookies/');
});
//End Google Cookie Choise //

$(document).ready(function () {

/* JBE Emailform submit */ 
$("#EmailAlertsForm, #EmailAlertsFormRegistered").submit(function (e) {
   e.preventDefault();
var email = $("#JBEemail").val();
var UserID = $("#JBEUserID").val();
var Validated = $("#JBEValidated").val();
var Sector = $("#JBESector").val();
var Region = $("#JBERegion").val();
var Location = $("#JBELocation").val();
var datastring = $("#EmailAlertsForm, #EmailAlertsFormRegistered").serialize();

if(email=='' || UserID=='') {
$('.error').fadeOut(200).show();
}
else {
$.ajax({
    type: "POST",
    url: "/actions/jbe.asp",
    data: dataString,
    success: function () {
$('.EmailAlertsForm').fadeOut(200).hide();
$('#EmailAlertsFormSuccess').fadeIn('slow');
if(UserID=='') {
$('#EmailAlertsFormSuccess').html('<span>' + email + '</span><br /><p>We have added ' + Sector + 'jobs ' + Region +', ' + Location +' to your alerts</p><div class="clearfix"></div>');
}
else{
$('#EmailAlertsFormSuccess').html('<span>Job Done !</span><p>We\'ll send you daily alerts about the latest ' + Sector + 'jobs in ' + Region +', ' + Location +' but before we do, please click the link on the email we have sent you to validate this email alert</p><div class="clearfix"></div>');
}
}
});
}
return false;
});
/* End JBE Emailform submit */ 


// End this script is the script that returns XML locations //	

$("#loc").autocomplete({
source: function (request, response) {
$.ajax({
url: "/scripts/locations.asp",
dataType: "xml",
data: {
"term": request.term
},
success: function (data) {
var items = [];
$("item", data).each(function (i, v) {
var item = {
location: $("location", v).text(),
region: $("region", v).text(),
label: $("label", v).text()
};
items.push(item);
})
response(items);
}
});
},
//			minLength: 2,
select: function (event, ui) {
$("#location").val(ui.item.location);
$("#region").val(ui.item.region);
$("#loc").val(ui.item.label);
}
});
// End this script is the script that returns XML locations //	

//Date Picker //
$(".datepicker").datepicker({
showOtherMonths: true,
selectOtherMonths: true
});
// End date picker //
/* Enable submitbutton */
$("input[type=submit]").removeAttr('disabled');
$("input[type=button]").removeAttr('disabled');
/* End Enable submitbutton */

//////////////////////////      Account Update    /////////////////////////////////

$("#Settings").submit(function(e){
e.preventDefault();
$.ajax({
type: "POST",
url: "/actions/updatesettings.asp",
data:$(this).serialize(),
success:function(result){
if(result==2){
// do something success
$('#SettingsUpdated').html('<p>Your account settings have been updated - thank you</p>');
$('#SettingsUpdated').fadeIn('slow');
}else {
// do something fail
$('#SettingsError').html('<p>Oops - something strange happened there - we were not able to update your settings - please try logging out of your account and logging back in.</p>');
$('#SettingsError').fadeIn('slow');
}
}});
}); 



        // grab the initial top offset of the navigation 
        var stickyNavTop = $('.nav').offset().top;
        // our function that decides weather the navigation bar should have "fixed" css position or not.
        var stickyNav = function () {
            var scrollTop = $(window).scrollTop(); // our current vertical position from the top

            // if we've scrolled more than the navigation, change its position to fixed to stick to top,
            // otherwise change it back to relative
            if (scrollTop > stickyNavTop) {
                $('.nav').addClass('sticky');
            } else {
                $('.nav').removeClass('sticky');
            }
        };
        stickyNav();
        // and run it again every time you scroll
        $(window).scroll(function () {
            stickyNav();
        });
    //End this script is the Sticky script //

	
	    //This script is the Twitter script //
    ! function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0],
            p = /^http:/.test(d.location) ? 'http' : 'https';
        if (!d.getElementById(id)) {
            js = d.createElement(s);
            js.id = id;
            js.src = p + '://platform.twitter.com/widgets.js';
            fjs.parentNode.insertBefore(js, fjs);
        }
    }(document, 'script', 'twitter-wjs'); // End this script is the Twitter script //
    //This script is the Facebook script //
    (function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s);
        js.id = id;
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
    //End this script is the Facebook script //
    //This script is the Google + script //
    window.___gcfg = {
        lang: 'en-GB'
    };

    (function () {
        var po = document.createElement('script');
        po.type = 'text/javascript';
        po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(po, s);
    })();
    //End this script is the Google + script //
    //This script is the Sticky script //
	});
//This script is the navigation expansion script //
function doSomething(elem) {
$(elem).parents("ul").children("li").show();
$(elem).parent("li").hide();
}
//End this script is the navigation expansion script //
  $(function() {
    $(".tooltip").tooltip();
  });

$('button.closefb').click(function(){
 $(this).fancybox.close();
});

//////////////////////////      Email a friend     /////////////////////////////////

  $("#Alert").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/emailnotification.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==1){
            // do something success
	      $('#AlertSuccess').html('<p>Your message has been sent!</p>');
          $('#AlertSuccess').fadeIn('slow');
     		 $.fancybox.close();
          }else {
            // do something fail
	      $('#AlertError').html('<p>Something strange happened! Please try again!/p>');
          $('#AlertError').fadeIn('slow');
          }
  	  }});
  });
  
  
//////////////////////////      Register    /////////////////////////////////

  $("#Register").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/register.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
     		 $('#RegisterFrm').fadeOut('fast');
			 $('#RegisterClose').fadeIn('slow');
          }else {
            // do something fail
			var email = $('#regemailaddress').val();
	      $('#RegisterError').html('<p>An account already exists with the username ' + email + '. Please either <a class="fancybox" href="#SignIn" rel="nofollow">Login</a> or <a class="fancybox" href="#PasswordRequestfrm" rel="nofollow">Reset your password</a></p>');
          $('#RegisterError').fadeIn('slow');
          }
  	  }});
  });
  
  
//////////////////////////      Login     /////////////////////////////////

  $("#SignIn").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/login.asp",
        data:$(this).serialize(),
		success:function(result){
          $('#SignInError1').hide();
          $('#SignInError2').hide();
         if(result==1){
            // do something fail
			var email = $('#signinusername').val();	
	      $('#SignInError1').html('<p>Sorry there is no account registered with the username ' + email + '. Please <a class="fancybox" href="#Register" rel="nofollow">register</a> an account to continue</p>');
          $('#SignInError1').fadeIn('slow');
          }
		  else if (result==2){
            // do something fail
			var email = $('#signinusername').val();
	      $('#SignInError2').html('<p>The password you have provided is not correct. Please try again or <a class="fancybox" href="#PasswordRequestfrm" rel="nofollow">Reset your password</a></p>');
          $('#SignInError2').fadeIn('slow');
          }
		  else {
            // do something success
     		 $.fancybox.close();
				if (location.pathname == '/passwordreset/passreset.asp') {
				  window.location = '/account/settings.asp';
				}
				else {
				   location.reload();
				}       
			 }
  	  }});
  });

//////////////////////////      Log Out     /////////////////////////////////

$("a.LogOut").click(function () {
var url = "http://www.mysiteUK.co.uk/actions/logout.asp";    
$(location).attr('href',url);
});

 //////////////////////////      PasswordRequest    /////////////////////////////////

  $("#PasswordRequestfrm").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/passwordrequest.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
     		 $.fancybox.close();
			 location.reload();
          }else {
            // do something fail
			var email = $('#passwordresetinput').val();
	      $('#PasswordResetError').html('<p>Sorry there is no account registered with the username ' + email + '. Please <a class="fancybox" href="#Register" rel="nofollow">register</a> an account to continue</p>');
          $('#PasswordResetError').fadeIn('slow');
          }
  	  }});
  });
  
   
 //////////////////////////      PasswordReset    /////////////////////////////////

  $("#PasswordReset").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/passwordreset.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
	      $('#PasswordResetConfirmation').html('<p>Your password has been reset. You can now <a class="fancybox" href="#SignIn" rel="nofollow">login</a> to your account using your new password.</p>');
          $('#PasswordResetError2').fadeOut('slow');
          $('#PasswordResetConfirmation').fadeIn('slow');

		  }
		  else {
            // do something fail
	      $('#PasswordResetError2').html('<p>Sorry we have experienced an error with your request. Please try to <a class="fancybox" href="#PasswordRequestfrm" rel="nofollow">reset your password</a> again.</p>');
          $('#PasswordResetError2').fadeIn('slow');
          }
  	  }});
  });
  
  
   
 //////////////////////////      Registered PasswordReset    /////////////////////////////////

  $("#RegisteredPasswordReset").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/registeredpasswordreset.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
	      $('#RegisteredPasswordResetConfirmation').html('<p>Your password has been reset.</p>');
          $('#RegisteredPasswordResetError2').fadeOut('slow');
          $('#RegisteredPasswordResetConfirmation').fadeIn('slow');

		  }
		  else {
            // do something fail
	      $('#RegisteredPasswordResetError2').html('<p>Sorry we have experienced an error with your request. Please try to reset your password again.</p>');
          $('#RegisteredPasswordResetError2').fadeIn('slow');
          }
  	  }});
  });
  
 
 //////////////////////////      Close Account    /////////////////////////////////
 
 $('.CloseAccountFancybox').click(function () {
        $.fancybox([
            { href : '#CloseAccount' }
        ]);
    });

  $("#CloseAccount").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/closeaccount.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
     		 $.fancybox.close();
			 $.cookie("UserAuth", null, { path: '/' });
			 var url = "http://www.mysiteUK.co.uk/";    
			 $(location).attr('href',url);
          }else {
            // do something fail
	      $('#CloseAccountError').html('<p>Oops - something strange happened there - we were not able to close your account, perhaps the password you provided was incorrect</p>');
          $('#CloseAccountError').fadeIn('slow');
          }
  	  }});
  }); 
  
  

//////////////////////////      Delete Alert    /////////////////////////////////
$('.deletealert').click(function () {
$("#AlertID").empty();
	$("#DeleteAlertSector").empty();
	$("#DeleteAlertLocation").empty();
	var AlertID = $(this).data('id');
	var DeleteAlertSector = $(this).data('sector');
	var DeleteAlertLocation = $(this).data('location');
	$("#AlertID").val(AlertID);
	$("#DeleteAlertSector").text(DeleteAlertSector);
	$("#DeleteAlertLocation").text(DeleteAlertLocation);
	$.fancybox([
		{ href : '#DeleteAlert' }
	]);
});   
  $("#DeleteAlert").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/deletecv.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==1){
            // do something success
     		 $(this).fancybox.close();
			 location.reload();
          }else {
            // do something fail
	      $('#DeleteAlertError').html('<p>ErrorMessage here</p>');
          $('#DeleteAlertError').fadeIn('slow');
          }
  	  }});
  });
  
 // Contact Us Tinymce Editor Load //
	
        $("#ContactUsLink a").click(function () {
            tinymce.init({
                selector: "textarea.addprofile",
                toolbar1: "paste | bold italic underline  | alignleft aligncenter alignright alignjustify | bullist numlist | ",
                menubar: false,
                toolbar_items_size: 'small',
                paste_as_text: true,
                browser_spellcheck: true,
                statusbar: false,
                height: 400,
                style_formats: [{
                    title: 'Bold text',
                    inline: 'b'
                }, ],
            });
       });	
		
//////////////////////////      ContactUs    /////////////////////////////////

  $("#Contact").submit(function(e){
      e.preventDefault();
    $.ajax({
		type: "POST",
        url: "/actions/contactus.asp",
        data:$(this).serialize(),
		success:function(result){
          if(result==2){
            // do something success
     		 $.fancybox.close();
			 location.reload();
          }else {
            // do something fail
	      $('#ContactError').html('<p>Oops - something strange happened there. Your email has not been sent. Please try again!</p>');
          }
  	  }});
  });
  
 

////////////////////////////// Fancy box ///////////////////////////////////////////////////
$('.fancybox:not(.fancybox\\.iframe)').fancybox(
{
fitToView: false,
autoDimensions : true,
padding : 8,
scrolling : false,
closeBtn: false,
speedIn : 100,
//overlayOpacity : 1,
//overlayColor : '#222',
autoScale     :   false,
autoSize : true
});

$("a.fancybox.fancybox\\.iframe").fancybox({
fitToView: false,
autoScale     :   false,
autoSize : false,				
height : 139,
width : 498,
scrolling : false,
closeBtn: false
});

////////////////////////////////////////////////////////////////////////////////////////////////////// 

Open in new window

Chris StanyonWebDevCommented:
Wow. That's a lot of scripts.

You'll neeed to be a little more specific than 'it's stopped working'! When you load up your page, take a look at the browser console and check on any errors you have.

Very first thing I see in your code is the letter v right at the start. Check that's not a typo because that would break it!
garethtnashAuthor Commented:
It's been a while - can you remind me how to use Console in Chrome? Thanks Chris
Chris StanyonWebDevCommented:
Sure - Just press F12 on your keyboard and you should see the WebDev tools, including the Console
garethtnashAuthor Commented:
Hi,

So have reduced the files, attempting to deal with one form at a time - so I have -

<% if ResultsCount >= 10 then %>
<% If (Request("Region") <> "") OR (Request("Sector") <> "") OR (Request("Location") <> "") OR (Request("id") <> "") then %>
<!--% If (Request("clientid") = "") AND (Request("jobtype") = "") AND (Request("hours") <> "") AND (Request("keywords") <> "") then %-->
<%if Session("UID") = ""  then %>
<!--#include virtual="/parts/unregisterjbe.asp" -->
<%Else%>
<!--#include virtual="/parts/registerjbe.asp" -->
<!--%End if%-->
<%End if%>
<%End if%>
<%End if%>

Open in new window


Then focusing on the unregisterjbe.asp section only I have -

<form action="" method="post" name="EmailAlertsForm" class="EmailAlertsForm clearfix" id="EmailAlertsForm">
  <legend>Get <%=(MetaPage)%> emailed job alerts
  <input name="Validated" type="hidden" id="JBEValidated" value="N">
  <input type="hidden" name="Sector" id="JBESector" value="<%=Request("Sector")%>">
  <input type="hidden" name="Region" id="JBERegion" value="<%=Request("Region")%>">
  <input type="hidden" name="Location" id="JBELocation" value="<%=Request("Location")%>">
  </legend>
  <label for="Username">Get the latest <%=(MetaPage)%> direct to your inbox</label>
  <div style="float: left; width: 278px; padding: 0px 4px 4px 4px; margin-top: 8px; background-color: #608EC7; border-radius: 4px;">
  <div style="float:left; width:236px; padding-top:4px;">
  <input name="Username" type="email" required id="JBEemail" placeholder="Email address" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" maxlength="255"/>
  </div>
  <div style="float: left; width: 42px; padding-top: 5px;">
  <input name="EmailSignUp" type="submit" disabled="disabled" id="EmailSignUp"  value="GO"/>
  </div>
  </div>
  <!--div class="paperPlane"></div-->
  <div class="clearfix"></div>
</form>
<div id="EmailAlertsFormSuccess" style="display:none;"></div>

Open in new window


I've stripped out the rest of the JQuery, so my JS file has -

$(document).ready(function () {
/* JBE Emailform submit */ 
$("#EmailAlertsForm").submit(function () {
var email = $("#JBEemail").val();
if(email=='') {
$('.error').fadeOut(200).show();
}
else {
$.ajax({
    type: "POST",
    url: "/actions/jbe.asp",
	data:$(this).serialize(),
    success: function () {
$('#EmailAlertsForm').fadeOut(200).hide();
$('#EmailAlertsFormSuccess').fadeIn('slow');
$('#EmailAlertsFormSuccess').html('<span>Job Done !</span><p>We\'ll send you daily alerts about the latest ' + Sector + 'jobs in ' + Region +', ' + Location +' but before we do, please click the link on the email we have sent you to validate this email alert</p><div class="clearfix"></div>');
}
});
}
return false;
});
});

Open in new window


When I test with console open - nothing happens??

Thanks
Chris StanyonWebDevCommented:
Hmmm. Difficult to see what's going on. So you have the Console open and you click on the submit button on your from and NOTHING happens. Is that right?

There are no errors showing up, you have jQuery loaded correctly, your HTML is being generated correctly (not the server-side script, but the actual HTML generated in your browser - View Source to be sure).

Do you have a link to a working demo of this page so I can take a closer look at what's going on.
garethtnashAuthor Commented:
I found it :)

<input name="EmailSignUp" type="submit" disabled="disabled" id="EmailSignUp"  value="GO"/>

Hey is there a site / resource where I can validate my JQuery?

Thanks
Chris StanyonWebDevCommented:
Nice one. That kind of clashes with your original question, but pleased you've got it sorted.

Not aware of any sites to validate jQuery specifically, but you could do worse than running your scripts through JSLint - http://www.jslint.com/. It will pick up many javascript issues and help you code better, so always worth doing.
garethtnashAuthor Commented:
TY :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.