Submit Form To Multiple Pages
Jquery Code
$(document).ready(function(){

        $('#targets').submit(function() {
  var error=0;

    $('#name_error_msg').html('').parent().hide();
    $('#section_error_msg').html('').parent().hide();
    $('#message_error_msg').html('').parent().hide();

    var name = $('#name').val();
    var section = $('#section').val();
    var message = $('#message').val();
    if(section == '0'){
         error = 1;
         $('#section_error_msg').html("Please select a section");
         $('#section_error_msg').parent().show();
    }
    if(name == ''){
        error = 1;
        $('#name_error_msg').html("Name cannot be empty");
        $('#name_error_msg').parent().show();
    }
    if(message == ''){
        error = 1;
        $('#message_error_msg').html("Message cannot be empty");
        $('#message_error_msg').parent().show();
    }

    if(error){
        return false;
    }else{
        switch(section){
            case 'home':

                $('#targets').attr('action','https://innovativephp.com');
                break;

            case 'ipress':
                $('#targets').attr('action','https://innovativephp.com/ipress');
                break;

            case 'isearch':
                $('#targets').attr('action','https://innovativephp.com/search');
                break;

            case 'tutorials':
                $('#targets').attr('action','https://innovativephp.com/tutorials');
                break;
               }
        return true;
    }
});

});
HTML Code
  • Section
  •  
     
  • Name
  •  
     
  • Message
  •  
     
  •  

Follow Me On Twitter

Advertise Here

Follow Us On Facebook