Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Good luck!
Need your opinion ...

A page has connected scripts js. Errors in the debugger is not detected.
On the details page of the product there is a button "book", which is initially inactive.
In going to this page after the checkbox, function works js, which makes the active button to submit the form.
By clicking on the button - function works AJAX.
The problem is that once again works through AJAX and activity buttons - with no errors.
What nonsense is this, do not even know where to dig and how to find this needle in a haystack.
Thank you!
<script type="text/javascript" src="my.js"></script>

Locate at page my.js file with my js code:

JavaScript
$(function() {

    $('#search_result').dblclick(function() {
        $(this).hide();
   
    });
    $("#search input[type=submit]").click(function() {
    $.ajax({
      url:"/engine/controller/search.php",
      type:"POST",
      dataType: 'json',
      data: {id: $("input[name=search_word]").val()},
      success:function(result){ 
        GetSearchResult(result);
      }
    });
    return false;
    });

$("input[name=tos]").click(function() {
    var checked_status = this.checked;
    if (checked_status == true) {
       $(".tos .but").removeAttr("disabled").addClass('but_active');
    } else {
       $(".tos .but").attr("disabled", "disabled").removeClass('but_active');
    }
});

    
$("#rez").click(function() {

  var email = $("#email").val();
  var name = $("#name").val();
  var phone = $("#phone").val();
  var info = $("#info").val();
  var id = $("#id").val();

$.ajax({
  type: 'POST',
  url: '/rezervation.php',
  dataType : 'json',
  data: 'email='+email+'&name='+name+'&phone='+phone+'&info='+info+'&id='+id,
  success: function(data){
    var block = '#mes';
    if (data.statuse == 1 ) {block = ''; $('.tos table').hide();} 
      $('.tos '+block).html(''+data.message[0]+'');
 
  }
});
});

function GetSearchResult(result){

          var html ='';
          if (result.message == undefined) {
          html = 'ID: '+result[4].val+''+result[1].val+''+result[5].val+' €';
          } else {
              html = ''+result.message+'';
          }

          $("#search_result div").html(html);
          $("#search_result").show();
}

function validateEmail(email) { 
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
}

function validate(){
  
  var email = $("#email").val();
  $("#email").css('border','auto');
  if (!validateEmail(email)) {
   
   alert('Email is not correct');
   $("#email").css('border','1px solid red');
   $("#email").val('');
   //$(".tos .but").attr("disabled", "disabled").removeClass('but_active');
   
  }
  return false;
}

});



Here is HTML:

        <label>
            <input type="checkbox" name="tos" value="1"> I read Terms and Conditions
        </input></label>







        Name
        <input type="text" class="field" id="name" name="data[name]">


        E-mail
        <input id="email" type="text" onblur="validate();" class="field" name="data[mail]">


        Telefon
        <input type="text" class="field" id="phone" name="data[phone]">


        Info

            <textarea class="textfield" id="info" name="data[info]"></textarea>





            <input type="hidden" name="id" id="id" value="40">
            Book





<input type="hidden" name="ac" value="send_msg"></input></input></input></input></input>
Posted
Updated 28-Feb-13 9:00am
v2
Comments
Richard C Bishop 28-Feb-13 14:08pm    
I am now understanding why you started your thread with "Good luck!". I tried real hard to understand your post and was not able to get it. ;) Jokes aside, it may be necessary for you to rephrase your question in a manner that makes more sense and add more detail about what is not working. Post the code you have as well using the "Improve question" widget.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900